Monty374

JFX 6.1

Dec 5th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. package javafxdemo;
  2.  
  3. import javafx.application.Application;
  4. import javafx.event.ActionEvent;
  5. import javafx.event.EventHandler;
  6. import javafx.scene.Scene;
  7. import javafx.scene.control.Button;
  8. import javafx.scene.layout.StackPane;
  9. import javafx.stage.Stage;
  10.  
  11. /**
  12. *
  13. * @author Monty
  14. */
  15. public class JavaFXDemo extends Application {
  16.  
  17. @Override
  18. public void start(Stage primaryStage) {
  19. Button btn = new Button();
  20. btn.setText("Say 'Hello World'");
  21. btn.setOnAction(new EventHandler<ActionEvent>() {
  22.  
  23. @Override
  24. public void handle(ActionEvent event) {
  25. System.out.println("Welcome to Java FX");
  26. }
  27. });
  28.  
  29. StackPane root = new StackPane();
  30. root.getChildren().add(btn);
  31.  
  32. Scene scene = new Scene(root, 300, 250);
  33.  
  34. primaryStage.setTitle("Hello World!");
  35. primaryStage.setScene(scene);
  36. primaryStage.show();
  37. }
  38.  
  39. /**
  40. * @param args the command line arguments
  41. */
  42. public static void main(String[] args) {
  43. launch(args);
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment