Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. package lab10;
  2. import javafx.application.Application;
  3. import javafx.scene.Scene;
  4. import javafx.scene.control.Label;
  5. import javafx.scene.input.MouseEvent;
  6. import javafx.geometry.Pos;
  7. import javafx.stage.Stage;
  8. import javafx.scene.layout.BorderPane;
  9. import javafx.event.EventHandler;
  10.  
  11. public class ThirdFx extends Application {
  12.  
  13. BorderPane root = new BorderPane();
  14.  
  15. Label lblTop = new Label("NORTH");
  16. Label lblBottom = new Label("SOUTH");
  17. Label lblLeft = new Label("WEST");
  18. Label lblRight = new Label("EAST");
  19. Label lblCenter = new Label("CENTER");
  20.  
  21. public static void main(String[] args) {
  22. Application.launch(args);
  23. }
  24. @Override
  25. public void start(Stage primaryStage) {
  26.  
  27. root.setTop(lblTop);
  28. root.setBottom(lblBottom);
  29. root.setLeft(lblLeft);
  30. root.setRight(lblRight);
  31. root.setCenter(lblCenter);
  32.  
  33. BorderPane.setAlignment(lblTop,Pos.CENTER);
  34. BorderPane.setAlignment(lblBottom,Pos.CENTER);
  35. BorderPane.setAlignment(lblLeft,Pos.CENTER);
  36. BorderPane.setAlignment(lblRight,Pos.CENTER);
  37. BorderPane.setAlignment(lblCenter,Pos.CENTER);
  38.  
  39. Scene scene = new Scene(root);
  40.  
  41. root.getTop().setOnMouseEntered(new EventHandler<MouseEvent>() {
  42. public void handle(MouseEvent event) {
  43. System.out.println("Welcome to Hail");
  44. }
  45. });
  46.  
  47. root.getBottom().setOnMouseEntered(new EventHandler<MouseEvent>() {
  48. public void handle(MouseEvent event) {
  49. System.out.println("Welcome to Abha");
  50. }
  51. });
  52.  
  53. root.getLeft().setOnMouseEntered(new EventHandler<MouseEvent>() {
  54. public void handle(MouseEvent event) {
  55. System.out.println("Welcome to Jeddah");
  56. }
  57. });
  58.  
  59. root.getRight().setOnMouseEntered(new EventHandler<MouseEvent>() {
  60. public void handle(MouseEvent event) {
  61. System.out.println("Welcome to Dhahran");
  62. }
  63. });
  64.  
  65. root.getCenter().setOnMouseEntered(new EventHandler<MouseEvent>() {
  66. public void handle(MouseEvent event) {
  67. System.out.println("Welcome to Riyadh");
  68. }
  69. });
  70.  
  71.  
  72. primaryStage.setY(0);
  73. primaryStage.setX(0);
  74. primaryStage.setMinHeight(500);
  75. primaryStage.setMinWidth(500);
  76. primaryStage.setTitle("Exercises1");
  77. primaryStage.setScene(scene);
  78. primaryStage.show();
  79.  
  80.  
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement