Example usage for javafx.scene.control Button Button

List of usage examples for javafx.scene.control Button Button

Introduction

In this page you can find the example usage for javafx.scene.control Button Button.

Prototype

public Button() 

Source Link

Document

Creates a button with an empty string for its label.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Button btn = new Button();
    btn.setText("Say 'Hello World'");
    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override/*from  ww w  . ja  va  2 s .  com*/
        public void handle(ActionEvent event) {
            System.out.println("Hello World!");
        }
    });

    StackPane root = new StackPane();
    root.getChildren().add(btn);

    Scene scene = new Scene(root, 300, 250);

    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane(4, 3);
    flowPane.setPrefWrapLength(210);/*from  www .j  ava2  s  .c  om*/
    Button btn = new Button();

    for (int i = 0; i < 8; i++) {
        btn = new Button("Button");
        btn.setPrefSize(100, 50);
        flowPane.getChildren().add(btn);
    }
    Scene scene = new Scene(flowPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Hello World!");
    Button btn = new Button();
    btn.setText("Say 'Hello World'");
    btn.setOnAction(new EventHandler<ActionEvent>() {
        @Override//from   w  w w . j  ava  2 s .c  o  m
        public void handle(ActionEvent event) {
            System.out.println("Hello World!");
        }
    });

    StackPane root = new StackPane();
    root.getChildren().add(btn);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {

    Button btn = new Button();
    final Label lbl = new Label();

    primaryStage.setTitle("Hello World!");

    lbl.setLayoutX(70);/* ww  w  . ja  v a 2 s. c om*/
    lbl.setLayoutY(150);

    btn.setLayoutX(100);
    btn.setLayoutY(100);
    btn.setText("Hello, World!");

    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            lbl.setText("Hello, World.");
        }
    });

    Group root = new Group();

    root.getChildren().add(btn);
    root.getChildren().add(lbl);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    Button btn = new Button();
    btn.setText("Hello World");
    btn.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            System.out.println("Hello World");
        }/*ww  w.j a v a 2s.  c  om*/
    });
    root.getChildren().add(btn);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL);
    flowPane.setPrefWrapLength(210);/*w  ww  .j av a2 s . c  o m*/
    Button btn = new Button();

    for (int i = 0; i < 8; i++) {
        btn = new Button("Button");
        btn.setPrefSize(100, 50);
        flowPane.getChildren().add(btn);
    }
    Scene scene = new Scene(flowPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL, 20, 20);
    flowPane.setPrefWrapLength(210);//from w  ww . java 2  s  .c  o  m
    Button btn = new Button();

    for (int i = 0; i < 8; i++) {
        btn = new Button("Button");
        btn.setPrefSize(100, 50);
        flowPane.getChildren().add(btn);
    }
    Scene scene = new Scene(flowPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL, 20, 20);
    flowPane.setPrefWrapLength(210);//  w w w  .  ja  v a 2 s.c  o  m
    Button btn = new Button();

    for (int i = 0; i < 8; i++) {
        btn = new Button("Button");
        btn.setPrefSize(100, 50);
        flowPane.getChildren().add(btn);
    }
    flowPane.setOrientation(Orientation.HORIZONTAL);

    Scene scene = new Scene(flowPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    Button btn = new Button();
    btn.setText("Hello World");

    btn.setOnMouseEntered(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            System.out.println("Mouse entered");
        }//from w  w  w.  j a  va2s  . co m
    });

    btn.setOnMouseExited(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            System.out.println("Mouse exited");
        }
    });

    btn.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            System.out.println("Mouse pressed");
        }
    });

    root.getChildren().add(btn);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL, 20, 20);
    flowPane.setPrefWrapLength(210);/*w ww .  j  a  va 2s.c  o m*/
    Button btn = new Button();

    for (int i = 0; i < 8; i++) {
        btn = new Button("Button");
        btn.setPrefSize(100, 50);
        flowPane.getChildren().add(btn);
    }
    flowPane.setRowValignment(VPos.BASELINE);

    Scene scene = new Scene(flowPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}