JavaFX Stage create second Stage

Description

JavaFX Stage create second Stage

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class Main extends Application {
  @Override//from www  .ja  va2 s . c  om
  public void start(Stage primaryStage) {
    // Create a scene and place a button in the scene
    Scene scene = new Scene(new Button("OK"), 200, 250);
    primaryStage.setTitle("MyJavaFX");
    primaryStage.setScene(scene);
    primaryStage.show();

    Stage stage = new Stage(); // Create a new stage
    stage.setTitle("Second Stage");
    // Set a scene with a button in the stage
    stage.setScene(new Scene(new Button("New Stage"), 100, 100));        
    stage.show();
  }
  

  public static void main(String[] args) {
    launch(args);
  }
}



PreviousNext

Related