Как запомнить данные введенные форме JavaFX?
В форме ввода на javafx ввожу логин , как мне его запомнить в коде, чтобы использовать в других окнах . При использовании в другом окне Login.getText(); значение строки получаю null public class Login {
@FXML
private ResourceBundle resources;
@FXML
private URL location;
@FXML
private AnchorPane pale1;
@FXML
private PasswordField passPale;
@FXML
public TextField LoginPale;
public void setLoginPale(TextField loginPale) {
LoginPale = loginPale;
}
public TextField getLoginPale() {
return LoginPale;
}
@FXML
private Text label1;
@FXML
private Button bSingIn;
@FXML
private ImageView img2;
@FXML
private ImageView img3;
@FXML
private ImageView imgmain;
@FXML
private Text label2;
@FXML
private Button bSingUp;
@FXML
private Text label3;
@FXML
private ImageView imgkomp;
@FXML
public void g(){
bSingIn.getScene().getWindow();
FXMLLoader loader0= new FXMLLoader();
loader0.setLocation(getClass().getResource("/sample/materials.fxml"));
try {
loader0.load();
} catch (IOException e) {
e.printStackTrace();
}
Parent root0 = loader0.getRoot();
Stage stage0 = new Stage();
stage0.setScene(new Scene(root0));
stage0.showAndWait();
}
@FXML
void initialize() {
bSingIn.setOnAction(
actionEvent -> {
try {
ResultSet result = Main.statement.executeQuery(
"SELECT id FROM usersStudents WHERE login=\'"+LoginPale.getText()+"\'AND passworduser=\'"+
passPale.getText()+"\'");
if (result.next()){
g();
} else{
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Error");
alert.setHeaderText(null);
alert.setContentText("Неправильный логин или пароль !");
alert.showAndWait();
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
);
bSingUp.setOnAction(
actionEvent -> {
bSingIn.getScene().getWindow().hide();
FXMLLoader loader11= new FXMLLoader();
loader11.setLocation(getClass().getResource("/sample/second.fxml"));
try {
loader11.load();
} catch (IOException e) {
e.printStackTrace();
}
Parent root = loader11.getRoot();
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.show();
}
);
assert pale1 != null : "fx:id=\"pale1\" was not injected: check your FXML file 'sample.fxml'.";
assert passPale != null : "fx:id=\"passPale\" was not injected: check your FXML file 'sample.fxml'.";
assert LoginPale != null : "fx:id=\"LoginPale\" was not injected: check your FXML file 'sample.fxml'.";
assert label1 != null : "fx:id=\"label1\" was not injected: check your FXML file 'sample.fxml'.";
assert bSingIn != null : "fx:id=\"bSingIn\" was not injected: check your FXML file 'sample.fxml'.";
assert img2 != null : "fx:id=\"img2\" was not injected: check your FXML file 'sample.fxml'.";
assert img3 != null : "fx:id=\"img3\" was not injected: check your FXML file 'sample.fxml'.";
assert imgmain != null : "fx:id=\"imgmain\" was not injected: check your FXML file 'sample.fxml'.";
assert label2 != null : "fx:id=\"label2\" was not injected: check your FXML file 'sample.fxml'.";
assert bSingUp != null : "fx:id=\"bSingUp\" was not injected: check your FXML file 'sample.fxml'.";
assert label3 != null : "fx:id=\"label3\" was not injected: check your FXML file 'sample.fxml'.";
assert imgkomp != null : "fx:id=\"imgkomp\" was not injected: check your FXML file 'sample.fxml'.";
}
}