Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab10;
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.control.Label;
- import javafx.scene.input.MouseEvent;
- import javafx.geometry.Pos;
- import javafx.stage.Stage;
- import javafx.scene.layout.BorderPane;
- import javafx.event.EventHandler;
- public class ThirdFx extends Application {
- BorderPane root = new BorderPane();
- Label lblTop = new Label("NORTH");
- Label lblBottom = new Label("SOUTH");
- Label lblLeft = new Label("WEST");
- Label lblRight = new Label("EAST");
- Label lblCenter = new Label("CENTER");
- public static void main(String[] args) {
- Application.launch(args);
- }
- @Override
- public void start(Stage primaryStage) {
- root.setTop(lblTop);
- root.setBottom(lblBottom);
- root.setLeft(lblLeft);
- root.setRight(lblRight);
- root.setCenter(lblCenter);
- BorderPane.setAlignment(lblTop,Pos.CENTER);
- BorderPane.setAlignment(lblBottom,Pos.CENTER);
- BorderPane.setAlignment(lblLeft,Pos.CENTER);
- BorderPane.setAlignment(lblRight,Pos.CENTER);
- BorderPane.setAlignment(lblCenter,Pos.CENTER);
- Scene scene = new Scene(root);
- root.getTop().setOnMouseEntered(new EventHandler<MouseEvent>() {
- public void handle(MouseEvent event) {
- System.out.println("Welcome to Hail");
- }
- });
- root.getBottom().setOnMouseEntered(new EventHandler<MouseEvent>() {
- public void handle(MouseEvent event) {
- System.out.println("Welcome to Abha");
- }
- });
- root.getLeft().setOnMouseEntered(new EventHandler<MouseEvent>() {
- public void handle(MouseEvent event) {
- System.out.println("Welcome to Jeddah");
- }
- });
- root.getRight().setOnMouseEntered(new EventHandler<MouseEvent>() {
- public void handle(MouseEvent event) {
- System.out.println("Welcome to Dhahran");
- }
- });
- root.getCenter().setOnMouseEntered(new EventHandler<MouseEvent>() {
- public void handle(MouseEvent event) {
- System.out.println("Welcome to Riyadh");
- }
- });
- primaryStage.setY(0);
- primaryStage.setX(0);
- primaryStage.setMinHeight(500);
- primaryStage.setMinWidth(500);
- primaryStage.setTitle("Exercises1");
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement