我正试图在新主题中从我的主场景开始一个新场景。
这是我的操作按钮:
private void handleButtonAction(ActionEvent event) throws IOException {
Thread t1 = new Thread(new OpenScene());
t1.start();
带有实现Runnable的OpenScene类
public class OpenConsole implements Runnable {
@Override
public void run() {
System.out.println("hello from run");
try {
Parent root = FXMLLoader.load(getClass().getResource("FXMLConsole.fxml"));
Scene scene = new Scene(root);
Stage stage = new Stage();
stage.setScene(scene);
stage.initModality(Modality.WINDOW_MODAL);
stage.showAndWait();
} catch (IOException ex) {
Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
我能够从跑步中打印一份声明,但我没有看到新的场景/舞台。