我目前正在使用两个控制器类.
在Controller1中,它创建一个在主要阶段之上打开的新阶段.
Stage stage = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("Controller2.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
Run Code Online (Sandbox Code Playgroud)
现在一旦这个阶段打开,我希望它在关闭之前保持打开约5秒钟.
在Controller2中,我尝试过实现类似的东西
long mTime = System.currentTimeMillis();
long end = mTime + 5000; // 5 seconds
while (System.currentTimeMillis() > end)
{
//close this stage
}
Run Code Online (Sandbox Code Playgroud)
但我不知道在while循环中放入什么来关闭它.我尝试了各种各样的东西,没有任何作用.