document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import javafx.application.Application;
  2. import javafx.event.ActionEvent;
  3. import javafx.event.EventHandler;
  4. import javafx.scene.Group;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.Button;
  7. import javafx.scene.layout.StackPane;
  8. import javafx.scene.text.Text;
  9. import javafx.stage.Stage;
  10.  
  11. /**
  12.  *
  13.  * @author zoranpavlovic.blogspot.com
  14.  */
  15. public class CreateDialog extends Application {
  16.     /**
  17.      * @param args
  18.      *            the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.         Application.launch(args);
  22.     }
  23.  
  24.     @Override
  25.     public void start(final Stage primaryStage) {
  26.         primaryStage.setTitle("Dialog");
  27.  
  28.         StackPane sp = new StackPane();
  29.         Button btnOpen = new Button("Open Dialog");
  30.         sp.getChildren().add(btnOpen);
  31.  
  32.         // Add action to open a new dialog
  33.         btnOpen.setOnAction(new EventHandler<ActionEvent>() {
  34.             public void handle(ActionEvent event) {
  35.                 // Creating a new Stage and showing it
  36.                 Stage stage = new Stage();
  37.                 Scene page2 = new Scene(new Group(new Text(20, 20,"This is a new dialog!")));
  38.                 stage.setScene(page2);
  39.                 stage.show();
  40.             }
  41.         });
  42.  
  43.         // Adding StackPane to the scene
  44.         Scene scene = new Scene(sp, 300, 200);
  45.         primaryStage.setScene(scene);
  46.         primaryStage.show();
  47.     }
  48. }
');