0
votes

Sembako.java this Main class

public class Sembako extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("rootScene.fxml"));

        Scene scene = new Scene(root);

        stage.setScene(scene);
        stage.setTitle("Login");
        stage.setResizable(false);
        stage.show();
    }

rootSceneController.java

@FXML private void loginAction(ActionEvent event) throws IOException {

for (indrian16.oulook.id.co.sembako.entity.Login l : listLogin) {

    if(username.getText().equals(l.getUsername())) {
        if(password.getText().equals(l.getPassword())) {
            Parent rootDashBoard = FXMLLoader.load(getClass().getResource("dashboard.fxml"));

            Stage stage = new Stage();
            Scene scene = new Scene(rootDashBoard);
            stage.setScene(scene);
            stage.setTitle("Sembako");
            stage.show();

            stage.close(); //how close Sembako scene :)

        } else {
            msgLogin.setText("Password Invalid");
        }
    } else {
        msgLogin.setText("Username Invalid");
    }

}

}

how close window Sembako scene in rootSceneController.java

sorry my bad english

1

1 Answers

1
votes

I think you are asking how to close the previously-opened window. Assuming this is the window containing the username text field, you can do

username.getScene().getWindow().hide();