package ch.hepia;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class Main extends Application {

    @Override
    public void start(Stage stage) {

        Label l = new Label("No message");
        Button b = new Button("Click me!");
        int[] nb = {0}; // A lambad could refer only references. Primitive types cannot be modified

        b.setOnAction( e -> l.setText( "Clicked " + ++nb[0] + " times") );

        VBox pane = new VBox(10); //new StackPane(l, b);
        pane.setAlignment(Pos.CENTER);
        pane.getChildren().add(b);
        pane.getChildren().add(l);
        Scene scene = new Scene(pane, 640, 480);

        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }

}