I'm working on a mini application where I need to display to users 2 windows at the same time.
I'm working with JavaFx Scene Builder 2.0 on NetBeans 8.0.1
is it possible to do this? if so, how it can be done ?
Thank you!
Join Stack Overflow to learn, share knowledge, and build your career.
I'm working on a mini application where I need to display to users 2 windows at the same time.
I'm working with JavaFx Scene Builder 2.0 on NetBeans 8.0.1
is it possible to do this? if so, how it can be done ?
Thank you!
By "screen" I assume you mean "window".
Just create a second stage in your start()
method and do exactly the same with it as you do your primary stage:
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); }
}