0
votes

I have this example of tabs implementation:

public class JavaFX_uiTabPane extends Application {

  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      launch(args);
  }

  @Override
  public void start(Stage primaryStage) {
      primaryStage.setTitle("http://java-buddy.blogspot.com/");
      Group root = new Group();
      Scene scene = new Scene(root, 400, 300, Color.WHITE);

      TabPane tabPane = new TabPane();
      BorderPane mainPane = new BorderPane();

      //Create Tabs
      Tab tabA = new Tab();
      tabA.setText("Tab A");
      tabPane.getTabs().add(tabA);

      Tab tabB = new Tab();
      tabB.setText("Tab B");
      tabPane.getTabs().add(tabB);

      Tab tabC = new Tab();
      tabC.setText("Tab C");
      tabPane.getTabs().add(tabC);

      mainPane.setCenter(tabPane);

      mainPane.prefHeightProperty().bind(scene.heightProperty());
      mainPane.prefWidthProperty().bind(scene.widthProperty());

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

I'm interested how I can make the component closeable. I want to put a small button at the right corner which when it's pressed the component is removed from the main stage. Is this possible with JavaFX?

1

1 Answers

1
votes

You can create your own tabs by extends Tab and try to customize it to include the small button you want. And after you will can add it to your TabPane