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" />
Add this line to your FXML code onAction="#handleButton1Action"
like
<TextField id="tittel" fx:id="tittel" onAction="#handleButton1Action" layoutX="120.0" layoutY="64.0" promptText="Tittel" />
and add this line after your controller class declaration
@FXML private TextField tittel;
then add the action handler
@FXML
private void handleButton1Action(ActionEvent event) {
System.out.println(tittel.getText());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With