Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javafx如何从其他类关闭窗口_Java_Javafx - Fatal编程技术网

javafx如何从其他类关闭窗口

javafx如何从其他类关闭窗口,java,javafx,Java,Javafx,java这个主类 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);

java这个主类

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 私有void登录操作(ActionEvent事件)引发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");
    }

}
}

rootSceneController.java中窗口Sembako场景的关闭程度


对不起,我的英语不好

我想你是在问如何关闭以前打开的窗口。假设这是包含
用户名
文本字段的窗口,您可以执行以下操作

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