JavaFX getText from textfield when button pressed(FX Builder)
javafx
Solution
Either add the action handler in the scene builder or add this to the FXML:
onAction="#handleButton1Action"
So in all:
<TextField id="tittel" fx:id="tittel" layoutX="120.0" layoutY="64.0" onAction="#handleButton1Action" promptText="Tittel" />
Problem
Currently in the process of learning myself JavaFX. I have used Scene Builder to create a simple Scene with a button, and a textfield. How come I can not click the button, and get the text from the textfield? ``` @FXML private void handleButton1Action(ActionEvent event) { System.out.println(tittel.getText()); } ``` The FXML code is : ``` <TextField id="tittel" fx:id="tittel" layoutX="120.0" layoutY="64.0" promptText="Tittel" /> ```