You can use the following method to create a tab title
private StackPane createTabHeader(String text, Node graphics){ return new StackPane(new Group(new Label(text, graphics))); }
Then call it in your code like this:
Tab tab = new Tab(); tab.setGraphic(createTabHeader("TEXT", new ImageView("IMAGE_PATH")));
Please note that you need to set the width and height of the tabs, as they will not automatically scale.
TabPane tabPane = new TabPane(tab); tabPane.setSide(Side.LEFT); tabPane.setTabMinWidth(50); tabPane.setTabMaxWidth(50); tabPane.setTabMinHeight(200); tabPane.setTabMaxHeight(200);
Mohamed handosa
source share