Grab text from Scene Builder to create account screen

Asked

Viewed 318 times

0

How to get text from FXML file?

field of the FXML file:

<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();
    }    

}

1 answer

1

Do not understand your question, but to get the value of a TextField, just have to use the method .getText(). In the contolator, in the method initialize, does not need to re-initialize the TextField.

 usernameSU.getText();

In Scenebuilder, you need to define the FXML File Controller.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.