/*
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 */

package helloworld;


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.KeyEvent;
import javafx.stage.Stage;

/**
 * @author rbair
 */
public class HelloButton extends Application {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override public void start(Stage stage) {
        stage.setTitle("Hello Button");
        Scene scene = new Scene(new Group(), 600, 450);
        Button button = new Button();
        button.setText("Click Me");
        button.setLayoutX(25);
        button.setLayoutY(40);

        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
                System.out.println("Event: " + e);
            }
        });

        button.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {
            @Override public void handle(KeyEvent e) {
                System.out.println("Event: " + e);
            }
        });

        ((Group)scene.getRoot()).getChildren().add(button);

        button = new Button();
        button.setText("Click Me Too");
        button.setLayoutX(25);
        button.setLayoutY(70);
        ((Group)scene.getRoot()).getChildren().add(button);

        button = new Button();
        button.setText("Click Me Three");
        button.setLayoutX(25);
        button.setLayoutY(100);
        ((Group)scene.getRoot()).getChildren().add(button);

        stage.setScene(scene);
        stage.setVisible(true);
    }
}
