JavaFx-Action With Lambda Expression

Program

dsad

Program Source

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.control.Button;

public class JavaFXApplication extends Application {
    
    private int count = 0;
    
    public static void main(String[] args) {

        Application.launch(args);
    }

    public void start(Stage primaryStage) {

        primaryStage.setTitle("Action With Lambda Expression");
        
        Group root = new Group();
        Scene scene = new Scene(root, 700, 200, Color.GRAY);
        
        Button btn = new Button("Button");
        btn.setLayoutX(100);
        btn.setLayoutY(100);
        btn.setOnAction(eve->{
            count++;
            btn.setText("count : "+count);
        });
        
        root.getChildren().add(btn);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

Leave a Comment