I have some JavaFX components declared in my fxml file.

and how do I get the values of the fields (Username, Password) when the button is pressed? (To perform the login).
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
stage.setTitle("Login");
stage.setScene(new Scene(root,400,300));
stage.show();
or is this the complete wrong way to do it?
My Questions:
EDIT : https://hastebin.com/qexipogoma.xml <- My FXML fie and my controller
Scene scene = stage.getScene();
Button btn = (Button) scene.lookup("#myBtnID");
TextField txt = (TextField ) scene.lookup("#myTxtID");
you're looking for:
txt.getText();
and
btn.setOnAction( lambda here );
Documentation:
Button
TextField
EDIT: declare ids this way
<TextField fx:id="myTxtID" ... />
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