roskenet/spring-javafx-examples

Not populating @FXML fields on initialize method

DiasNetoJ opened this issue · 1 comments

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
    }
}