Get text from scene builder to create account screen

0

How do I get text from the FXML file?

FXML file field:

<TextField fx:id="usernameSU" GridPane.columnIndex="1" />

Controller file:

public class signUpController implements Initializable {

    @FXML private TextField usernameSU;

    @FXML
    private void signUp(ActionEvent event) {
        System.out.println(""); //Imprimir TextField para teste
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        usernameSU = new TextField();
    }    

}
    
asked by anonymous 27.05.2017 / 19:12

1 answer

1

You do not understand your question, but to get the value of TextField , you only have to use the .getText() method. In the contoller, in the initialize method, you do not need to re-initialize TextField .

 usernameSU.getText();

In the SceneBuilder, you need to set the FXML File Controller.

    
29.05.2017 / 15:08