Wie kann ich TextField in JavaFX von der inneren Bühne holen?
Ich habe einen Controller für zwei Fenster / Stufen geschrieben. Das erste Fenster wird in der MainClass geöffnet. Die zweite im Controller, wenn der Benutzer auf eine Schaltfläche klickt. Wie kann ich die TextFields von second.fxml in der applyFor () - Methode erhalten?
Vielen Dank
@FXML
protected void requestNewAccount(ActionEvent event) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("second.fxml")); // TextFields in there
Parent root = (Parent) fxmlLoader.load();
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("Second Window");
Scene scene = new Scene(root);
String css = MainOnlineCustomer.class.getResource("/style.css").toExternalForm();
scene.getStylesheets().clear();
scene.getStylesheets().add(css);
stage.setScene(scene);
stage.show();
} catch (IOException e) {
logger.error(e);
}
}
/**
* closes the "second"-Window
* @param event
*/
@FXML
protected void cancel(ActionEvent event) {
final Node source = (Node) event.getSource();
final Stage stage = (Stage) source.getScene().getWindow();
stage.close();
}
@FXML
protected void applyFor(ActionEvent event) {
// get values from TextField in second.fxml here!!!
}