Skip to main content

Overview

JTabs is a flexible tab component that extends JavaFX’s BorderPane. It supports multiple visual styles (line, pills), tab positioning (top, bottom, left, right), and custom tab content with titles, descriptions, and icons.

Enumerations

TabStyle

LINE
TabStyle
Line-style tabs with an underline indicator
PILLS
TabStyle
Pill-style tabs with rounded backgrounds

Constructor

JTabs()
constructor
Creates a new tab container with default settings (LINE style, TOP position).

Methods

Tab Management

getTabs()
ObservableList<JTab>
Returns the observable list of tabs.
selectTab(JTab tab)
void
Programmatically selects a tab.

Style Configuration

getTabStyle()
TabStyle
Gets the current tab style.
setTabStyle(TabStyle style)
void
Sets the visual style of the tabs.
tabStyleProperty()
ObjectProperty<TabStyle>
Property for the tab style.

Position Configuration

getSide()
Side
Gets the current tab position.
setSide(Side side)
void
Sets the position of the tab headers.
sideProperty()
ObjectProperty<Side>
Property for the tab position.
  • JTab - Individual tab data objects for use within JTabs

Style Classes

j-tabs
String
Base style class applied to the tabs container
tabs-line
String
Applied when using LINE tab style
tabs-pills
String
Applied when using PILLS tab style
j-tabs-header
String
Applied to the container holding tab headers
j-tabs-content
String
Applied to the container holding tab content
j-tab
String
Applied to individual tab headers
selected
String
Applied to the currently selected tab header
tab-title
String
Applied to tab title labels
tab-description
String
Applied to tab description labels

Example Usage

// Create tabs container
JTabs tabs = new JTabs();

// Add tabs
tabs.getTabs().addAll(
    new JTab("Home", new Label("Home content")),
    new JTab("Profile", new Label("Profile content")),
    new JTab("Settings", new Label("Settings content"))
);

// Configure style
tabs.setTabStyle(JTabs.TabStyle.PILLS);
tabs.setSide(Side.LEFT);

// Tab with description and icon
JTab detailsTab = new JTab();
detailsTab.setTitle("Details");
detailsTab.setDescription("View detailed information");
detailsTab.setGraphic(JIcon.INFO.view());
detailsTab.setContent(new Label("Details content"));
tabs.getTabs().add(detailsTab);

// Programmatically select a tab
tabs.selectTab(tabs.getTabs().get(1));

// Bind to property changes
tabs.sideProperty().addListener((obs, old, newSide) -> {
    System.out.println("Tabs moved to: " + newSide);
});

Behavior Notes

  • Only one tab can be selected at a time
  • When tabs are positioned on TOP or BOTTOM, headers are horizontally scrollable if needed
  • When tabs are positioned on LEFT or RIGHT, headers are vertically arranged
  • Disabled tabs cannot be selected
  • The first tab is automatically selected when tabs are added to an empty container
  • Tab descriptions are only visible when set and non-empty

Source

com.jjarroyo.components.JTabs in JTabs.java:22

JTab

Overview

JTab is a data model class representing an individual tab within a JTabs container. It holds the tab’s title, description, content, icon, and disabled state.

Constructor

JTab()
constructor
Creates an empty tab.
JTab(String title, Node content)
constructor
Creates a tab with title and content.
JTab(String title, String description, Node content)
constructor
Creates a tab with title, description, and content.

Properties

Title

titleProperty()
StringProperty
Property for the tab title.
getTitle()
String
Gets the tab title.
setTitle(String title)
void
Sets the tab title.

Description

descriptionProperty()
StringProperty
Property for the tab description.
getDescription()
String
Gets the tab description.
setDescription(String description)
void
Sets the tab description.

Content

contentProperty()
ObjectProperty<Node>
Property for the tab content.
getContent()
Node
Gets the tab content.
setContent(Node content)
void
Sets the tab content.

Graphic

graphicProperty()
ObjectProperty<Node>
Property for the tab icon/graphic.
getGraphic()
Node
Gets the tab graphic.
setGraphic(Node graphic)
void
Sets the tab graphic (typically an icon).

Disable

disableProperty()
ObjectProperty<Boolean>
Property for the tab disabled state.
isDisable()
Boolean
Checks if the tab is disabled.
setDisable(Boolean disable)
void
Sets whether the tab is disabled.

Source

com.jjarroyo.components.JTab in JTab.java:9

Build docs developers (and LLMs) love