i.l*_*lly 2 netbeans javafx javafx-2 scenebuilder
我正在开发一个迷你应用程序,我需要同时向用户显示 2 个窗口。
我正在 NetBeans 8.0.1 上使用 JavaFx Scene Builder 2.0
是否有可能做到这一点?如果是这样,怎么做?
谢谢!
通过“屏幕”,我假设您的意思是“窗口”。
只需在您的start()方法中创建第二个阶段,并对其进行与您的主要阶段完全相同的操作:
public class MyApp extends Application {
@Override
public void start(Stage primaryStage) {
Stage anotherStage = new Stage();
try {
FXMLLoader loader = new FXMLLoader(...); // FXML for primary stage
Parent root = loader.load();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
FXMLLoader anotherLoader = new FXMLLoader(...) ; // FXML for second stage
Parent anotherRoot = anotherLoader.load();
Scene anotherScene = new Scene(anotherRoot);
anotherStage.setScene(anotherScene);
anotherStage.show();
} catch (Exception exc) {
exc.printStackTrace();
}
}
public static void main(String[] args) { launch(args); }
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5215 次 |
| 最近记录: |