Code :
package javafxtemplate1;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Stage;
/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
@Override
public void start(Stage primaryStage) {
Group groot = new Group();
//Lambda Expression
Button btn = new Button("Button");
btn.setLayoutX(100);btn.setLayoutY(80);
Label label1 = new Label("Label");
label1.setLayoutX(90);label1.setLayoutY(40);
btn.setOnAction((ActionEvent e) -> {
System.out.println("Hello World");
primaryStage.setTitle("Hello World");
});
groot.getChildren().addAll(btn, label1);
Scene scene = new Scene(groot, 200, 150);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}