digrach

main

Mar 27th, 2014
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.event.ActionEvent;
  3. import javafx.event.EventHandler;
  4. import javafx.stage.Stage;
  5. import javafx.scene.Scene;
  6. import javafx.scene.control.Button;
  7. import javafx.scene.layout.BorderPane;
  8.  
  9.  
  10. public class Main extends Application {
  11.  
  12.     private BorderPane root;
  13.     private Scene scene;
  14.  
  15.     @Override
  16.     public void start(Stage primaryStage) {
  17.         try {
  18.             root = new BorderPane();
  19.             scene = new Scene(root, 400, 400);
  20.             scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
  21.             addComponentsToStage();
  22.             primaryStage.setScene(scene);
  23.             primaryStage.show();
  24.         } catch(Exception e) {
  25.             e.printStackTrace();
  26.         }
  27.     }
  28.  
  29.     public static void main(String[] args) {
  30.         launch(args);
  31.     }
  32.  
  33.     public void addComponentsToStage() {
  34.         addParticleCanvasLauncher();
  35.  
  36.     }
  37.  
  38.     private void addParticleCanvasLauncher() {
  39.         Button button = new Button();
  40.         button.setText("Click here");
  41.         button.setOnAction(new EventHandler<ActionEvent>() {
  42.             @Override
  43.             public void handle(ActionEvent event) {
  44.                 final ParticleCanvas s = new ParticleCanvas();
  45.                 s.show();
  46.             }
  47.         });
  48.         root.setCenter(button);
  49.     }
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment