Ara*_*ash 2 javafx launch application-error
我正在使用javafx,想在一个按钮的'setOnAction'中编写代码来关闭javafx1类和运行javafx2类,但我看到错误'应用程序启动不能多次调用'.我怎样才能解决这个问题?
//This code is in the class JavaFX1:
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
JavaFX2.main(null); //How can i change current line?
stage.close();
}
});
Run Code Online (Sandbox Code Playgroud)
xue*_*eng 13
它是这样完成的:
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
Stage secondStage = new Stage();
secondStage.setScene(new Scene(new HBox(4, new Label("Second window"))));
secondStage.show();
}
Run Code Online (Sandbox Code Playgroud)
您还可以设置新窗口的坐标和大小.
| 归档时间: |
|
| 查看次数: |
11106 次 |
| 最近记录: |