Advertisement
Emon766

Click ME Demo

Nov 24th, 2021
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javafxdemo;
  7.  
  8. import javafx.application.Application;
  9. import javafx.event.ActionEvent;
  10. import javafx.event.EventHandler;
  11. import javafx.scene.Scene;
  12. import javafx.scene.control.Button;
  13. import javafx.scene.control.Label;
  14. import javafx.scene.layout.StackPane;
  15. import javafx.scene.layout.VBox;
  16. import javafx.stage.Stage;
  17.  
  18. /**
  19.  *
  20.  * @author Dell
  21.  */
  22. public class Main extends Application{
  23.     int abc=0;
  24.     public static void main(String[] args){
  25.         launch(args);
  26.     }
  27.    
  28.    
  29.     @Override
  30.     public void start(Stage stage) throws Exception {
  31.         Button btn = new Button("Click Me");
  32.         Label lbl = new Label();
  33.         btn.setOnAction(new EventHandler<ActionEvent>(){
  34.             @Override
  35.             public void handle(ActionEvent t) {
  36.                 //System.out.println("The Button is pressed");
  37.                 lbl.setText("Button Pressed");
  38.             }
  39.            
  40.        
  41.         });
  42.        
  43.        
  44.         VBox root = new VBox();
  45.         root.getChildren().addAll(btn,lbl);
  46.        
  47.         Scene scene = new Scene(root, 600, 400);
  48.         stage.setScene(scene);
  49.         stage.show();
  50.     }
  51.    
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement