TabbedPane

Swing component: JTabbedPane
Swing tutorial: How to Use Tabbed Panes

Properties

TabbedPane Properties

Colors

UI Key Style Key v2 Description
TabbedPane.foreground foreground tab text and forward/backward/more icon color if enabled
TabbedPane.disabledForeground disabledForeground tab text and forward/backward/more icon color if disabled
TabbedPane.background background tab area background color
TabbedPane.selectedForeground selectedForeground tab text color if selected (optional)
TabbedPane.selectedBackground selectedBackground tab background color if selected (optional)
TabbedPane.underlineColor underlineColor tab underline selection mark color if selected and (child) focused
TabbedPane.inactiveUnderlineColor v2.2 inactiveUnderlineColor tab underline selection mark color if selected but not (child) focused
TabbedPane.disabledUnderlineColor disabledUnderlineColor tab underline selection mark color if selected and disabled
TabbedPane.hoverForeground v3.1 hoverForeground tab text color if mouse is over tab (optional)
TabbedPane.hoverColor hoverColor tab background color if mouse is over tab (optional)
TabbedPane.focusForeground v3.1 focusForeground tab text color if tabbed pane is focused (optional)
TabbedPane.focusColor focusColor tab background color if tabbed pane is focused (optional)
TabbedPane.tabSeparatorColor tabSeparatorColor tab separator color and tab card border color (optional; defaults to TabbedPane.contentAreaColor)
TabbedPane.contentAreaColor contentAreaColor content separator color (line between tab area and content), content border color (if enabled with TabbedPane.hasFullBorder) and card border color
TabbedPane.buttonHoverBackground buttonHoverBackground forward/backward/more buttons background color if mouse is over button
TabbedPane.buttonPressedBackground buttonPressedBackground forward/backward/more buttons background color if mouse is pressed on button

Sizes

UI Key Style Key v2 Type Description
TabbedPane.tabAreaInsets tabAreaInsets Insets margin space between the tabbed pane bounds and the tab area
TabbedPane.tabInsets tabInsets Insets margin space between the tab bounds and the text
TabbedPane.textIconGap textIconGap int gap between icon and text
TabbedPane.minimumTabWidth minimumTabWidth int minimum width of a tab (optional)
TabbedPane.maximumTabWidth maximumTabWidth int maximum width of a tab (optional)
TabbedPane.tabHeight tabHeight int minimum height of a tab
TabbedPane.tabSelectionHeight tabSelectionHeight int height of underline selection mark (for tab type underlined)
TabbedPane.cardTabSelectionHeight v2 cardTabSelectionHeight int height of card selection mark (for tab type card)
TabbedPane.tabArc v3.2 tabArc int arc diameter of the tab background corners (for tab type underlined)
TabbedPane.tabSelectionArc v3.2 tabSelectionArc int arc diameter of the underline selection mark (for tab type underlined)
TabbedPane.cardTabArc v3.2 cardTabArc int arc diameter of the card border corners (for tab type card)
TabbedPane.selectedInsets v3.2 selectedInsets Insets insets of the tab background (for tab type underlined)
TabbedPane.tabSelectionInsets v3.2 tabSelectionInsets Insets insets of the underline selection mark (for tab type underlined)
TabbedPane.contentSeparatorHeight contentSeparatorHeight int thickness of content separator (line between tab area and content), content border (if enabled with TabbedPane.hasFullBorder) and card border
TabbedPane.buttonInsets buttonInsets Insets margin space between the forward/backward/more buttons bounds and the icon
TabbedPane.buttonArc buttonArc int arc diameter of the forward/backward/more buttons border corners
TabbedPane.tabRunOverlay - int specifies overlapping of tab runs (rows) in scroll layout policy

Other

UI Key Style Key v2 Type Description
TabbedPane.font font Font font used to render text
TabbedPane.tabsOpaque tabsOpaque boolean if true, fill tab area background
TabbedPane.opaque - boolean if true, sets property JTabbedPane.opaque to true
TabbedPane.­selectionFollowsFocus - boolean if true, some key combinations are available to switch to next/previous tab using keyboard (e.g. Ctrl+Tab, Ctrl+Shift+Tab, Ctrl+PageDown or Ctrl+PageUp); default is true
TabbedPane.­showTabSeparators showTabSeparators boolean if true, shows separator lines between tabs
TabbedPane.­tabSeparatorsFullHeight tabSeparatorsFullHeight boolean if true, tab separators have full height of tab area
TabbedPane.hasFullBorder hasFullBorder boolean if true, shows a border around the content area
TabbedPane.rotateTabRuns v2.5 rotateTabRuns boolean if true, tab runs (rows) in scroll layout policy are reordered so that the row that contains the selected tab is placed next to the content
TabbedPane.tabLayoutPolicy - String wrap (default) or scroll
TabbedPane.tabType tabType String

type of the selected tab:

  • underlined - Paint the selected tab underlined. (default)
  • card - Paint the selected tab as card.
TabbedPane.­tabsPopupPolicy tabsPopupPolicy String

display policy for the "more tabs" button, which shows a popup menu with the (partly) hidden tabs:

  • never - Display never.
  • asNeeded - Display only when needed. (default)
TabbedPane.­scrollButtonsPolicy scrollButtonsPolicy String

display policy for the forward/backward scroll arrow buttons:

  • never - Display never.
  • asNeeded - Display only when needed. Both scroll arrow buttons are either shown or hidden. Buttons are disabled if scrolling in that direction is not applicable.
  • asNeededSingle - Display single button only when needed. If scroll button placement is trailing, then this option is ignored and both buttons are shown or hidden as needed. (default)
TabbedPane.­scrollButtonsPlacement scrollButtonsPlacement String

placement of the forward/backward scroll arrow buttons.:

  • both - The forward/backward scroll arrow buttons are placed on both sides of the tab area. The backward scroll button at the left/top side. The forward scroll button at the right/bottom side. (default)
  • trailing - The forward/backward scroll arrow buttons are placed on the trailing side of the tab area.
TabbedPane.­tabAreaAlignment tabAreaAlignment String

alignment of the tab area within the tabbed pane:

  • leading - Align to the leading edge. (default)
  • trailing - Align to the trailing edge.
  • center - Align to center.
  • fill - Stretch to fill all available space.
TabbedPane.tabAlignment tabAlignment String

horizontal alignment of the tab title and icon:

  • leading - Align to the leading edge.
  • trailing - Align to the trailing edge.
  • center - Align to center. (default)
TabbedPane.tabWidthMode tabWidthMode String

specifies how the tabs should be sized:

  • preferred - Tab width is adjusted to tab icon and title. (default)
  • equal - All tabs in a tabbed pane has same width.
  • compact - Unselected tabs are smaller because they show only the tab icon, but no tab title. Selected tabs show both.
TabbedPane.tabRotation v3.3 tabRotation String

specifies the rotation of the tabs (title, icon, etc.):

  • none - Tabs are not rotated. (default)
  • auto - Tabs are rotated depending on tab placement. For top and bottom tab placement, the tabs are not rotated. For left tab placement, the tabs are rotated counter-clockwise. For right tab placement, the tabs are rotated clockwise.
  • left - Tabs are rotated counter-clockwise.
  • right - Tabs are rotated clockwise.
TabbedPane.closeIcon - Icon icon used for close buttons; usually a FlatTabbedPaneCloseIcon
TabbedPane.arrowType arrowType String chevron (default) or triangle
TabbedPane.­moreTabsButtonToolTipText moreTabsButton­ToolTipText String tooltip text used for "more tabs" button
TabbedPane.­tabCloseToolTipText v2 tabCloseToolTipText String tooltip text used for tab close buttons

Styling v2

Following properties are only available via styling (not in UI defaults, but has likewise client properties).

Style Key Type Description Client Property
showContentSeparator boolean if true, shows separator between tabs area and content area JTabbedPane.showContentSeparator
hideTabAreaWithOneTab boolean if true, hides tab area if it contains only one tab JTabbedPane.hideTabAreaWithOneTab
tabClosable boolean

if true, all tabs are closable

Note that you have to specify a callback (see client property JTabbedPane.tabCloseCallback that is invoked when the user clicks a tab close button. The callback is responsible for closing the tab.

JTabbedPane.tabClosable
tabIconPlacement int

tab icon placement (relative to tab title):

  • SwingConstants.LEADING - Place icon left to title. (default)
  • SwingConstants.TRAILING - Place icon right to title.
  • SwingConstants.TOP - Place icon above title.
  • SwingConstants.BOTTOM - Place icon below title.

JTabbedPane.tabIconPlacement