如何从another.class多次打开javafx gui,其中another.class就像本地gui和通过远程接口远程服务器之间的控制器... 例如:
public class JavaFxPlay extends Application {
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage primaryStage) throws Exception {
Label label = new Label("This is the main GUI");
VBox root = new VBox();
root.getChildren().add(label);
Scene scene = new Scene(root, 300, 200);
primaryStage.setScene(scene);
primaryStage.setTitle("Main");
showSecondaryStage();
primaryStage.show();
}
private void showSecondaryStage() {
Stage newStage = new Stage();
newStage.setTitle("Login");
Label label = new Label("Login here");
VBox root = new VBox();
root.getChildren().add(label);
Scene scene = new Scene (root, 100, 50);
newStage.setScene(scene);
newStage.showAndWait();
}
}
然后从其他类这样的东西
public class SetUp
{
//field 1
//field 2
public SetUp()
{
}
public sessionSetUp()
{
//some code, then launch main gui
Application.launch(JavaFxPlay.class); //this works
//main gui closes and exits after finishing
//some more code then i need to show the secondary stage of example
Application.launch(JavaFxPlay.showSecondaryStage()); //of course this is wrong, how to do this is my problem!!!
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
SetUp setup = new SetUp();
setup.sessionSetUp();
}
}