roskenet / spring-javafx-examples

Example apps for springboot-javafx-support. See
https://www.felixroske.de/page/programmierung/index.html
159 stars 66 forks source link

Not populating @FXML fields on initialize method #3

Closed DiasNetoJ closed 7 years ago

DiasNetoJ commented 7 years ago

Initializable controllers is not populating @FXML annotated fields, see example:

@FXMLController
public class Helloworld implements Initializable  {
    @FXML
    private Label helloLabel;

    @FXML
    private TextField nameField;

    @FXML
    private void setHelloText(final Event event) {
        final String textToBeShown = nameField.getText();
        helloLabel.setText(textToBeShown);
    }

    @FXML
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        nameField.setText("Testing..."); //NPE, cause nameField is null
    }
}
DiasNetoJ commented 7 years ago

https://github.com/roskenet/springboot-javafx-support/issues/27