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