1  import javafx.application.Application;
  2  import javafx.event.ActionEvent;
  3  import javafx.event.EventHandler;
  4  import javafx.geometry.Pos;
  5  import javafx.scene.Scene;
  6  import javafx.scene.control.Button;
  7  import javafx.scene.layout.StackPane;
  8  import javafx.scene.layout.HBox;
  9  import javafx.scene.layout.BorderPane;
 10  import javafx.scene.paint.Color;
 11  import javafx.scene.shape.Circle;
 12  import javafx.stage.Stage;
 13  
 14  public class ControlCircleWithLambdaExpression extends Application {
 15    private CirclePane circlePane = new CirclePane();
 16  
 17    @Override // Override the start method in the Application class
 18    public void start(Stage primaryStage) {
 19      // Hold two buttons in an HBox
 20      HBox hBox = new HBox();
 21      hBox.setSpacing(10);
 22      hBox.setAlignment(Pos.CENTER);
 23      Button btEnlarge = new Button("Enlarge");
 24      Button btShrink = new Button("Shrink");
 25      hBox.getChildren().add(btEnlarge);
 26      hBox.getChildren().add(btShrink);
 27      
 28      // Create and register the handler
 29      btEnlarge.setOnAction((ActionEvent e) ->  circlePane.enlarge());
 30  
 31      BorderPane borderPane = new BorderPane();
 32      borderPane.setCenter(circlePane);
 33      borderPane.setBottom(hBox);
 34      BorderPane.setAlignment(hBox, Pos.CENTER);
 35      
 36      // Create a scene and place it in the stage
 37      Scene scene = new Scene(borderPane, 200, 150);
 38      primaryStage.setTitle("ControlCircle"); // Set the stage title
 39      primaryStage.setScene(scene); // Place the scene in the stage
 40      primaryStage.show(); // Display the stage
 41    }
 42    
 43    /**
 44     * The main method is only needed for the IDE with limited
 45     * JavaFX support. Not needed for running from the command line.
 46     */
 47    public static void main(String[] args) {
 48      launch(args);
 49    }
 50  }