Class TabPane

All Implemented Interfaces:
Styleable, EventTarget, Skinnable

@DefaultProperty("tabs") public class TabPane extends Control
A control that allows switching between a group of Tabs. Only one tab is visible at a time. Tabs are added to the TabPane by using the getTabs().

Tabs in a TabPane can be positioned at any of the four sides by specifying the Side.

A TabPane has two modes floating or recessed. Applying the styleclass STYLE_CLASS_FLOATING will change the TabPane mode to floating.

The tabs width and height can be set to a specific size by setting the min and max for height and width. TabPane default width will be determined by the largest content width in the TabPane. This is the same for the height. If a different size is desired the width and height of the TabPane can be overridden by setting the min, pref and max size.

When the number of tabs do not fit the TabPane a menu button will appear on the right. The menu button is used to select the tabs that are currently not visible.

Example:

 TabPane tabPane = new TabPane();
 Tab tab = new Tab();
 tab.setText("new tab");
 tab.setContent(new Rectangle(100, 50, Color.LIGHTSTEELBLUE));
 tabPane.getTabs().add(tab);
Image of the TabPane control
Since:
JavaFX 2.0
See Also:
  • Property Details

    • selectionModel

      public final ObjectProperty<SingleSelectionModel<Tab>> selectionModelProperty
      The selection model used for selecting tabs. Changing the model alters how the tabs are selected and which tabs are first or last.
      See Also:
    • side

      public final ObjectProperty<Side> sideProperty
      The position to place the tabs in this TabPane. Changes to the value of this property immediately updates the location of the tabs.
      Default value:
      Side.Top
      See Also:
    • tabClosingPolicy

      public final ObjectProperty<TabPane.TabClosingPolicy> tabClosingPolicyProperty
      Specifies how the TabPane handles tab closing from an end-user's perspective.

      Refer to the TabPane.TabClosingPolicy enumeration for further details.

      Default value:
      TabClosingPolicy.SELECTED_TAB
      See Also:
    • rotateGraphic

      public final BooleanProperty rotateGraphicProperty
      Specifies whether the graphic inside a Tab is rotated or not, such that it is always upright, or rotated in the same way as the Tab text is.

      If the value is false, the graphic isn't rotated, resulting in it always appearing upright. If the value is true, the graphic is rotated with the Tab text.

      Default value:
      false
      See Also:
    • tabMinWidth

      public final DoubleProperty tabMinWidthProperty
      The minimum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-min-width.

      Default value:
      0
      See Also:
    • tabMaxWidth

      public final DoubleProperty tabMaxWidthProperty
      The maximum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. If the Tab text is longer than the maximum width, the text will be truncated. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-max-width.

      Default value:
      Double.MAX_VALUE
      See Also:
    • tabMinHeight

      public final DoubleProperty tabMinHeightProperty
      The minimum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-min-height.

      Default value:
      0
      See Also:
    • tabMaxHeight

      public final DoubleProperty tabMaxHeightProperty
      The maximum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-max-height.

      Default value:
      Double.MAX_VALUE
      See Also:
    • tabDragPolicy

      public final ObjectProperty<TabPane.TabDragPolicy> tabDragPolicyProperty
      The drag policy for the tabs. It specifies if tabs can be reordered or not.
      Default value:
      TabDragPolicy.FIXED
      Since:
      10
      See Also:
  • Field Details

    • STYLE_CLASS_FLOATING

      public static final String STYLE_CLASS_FLOATING
      TabPane mode will be changed to floating allowing the TabPane to be placed alongside other control.
      See Also:
  • Constructor Details

    • TabPane

      public TabPane()
      Constructs a new TabPane.
    • TabPane

      public TabPane(Tab... tabs)
      Constructs a new TabPane with the given tabs set to show.
      Parameters:
      tabs - The tabs to display inside the TabPane.
      Since:
      JavaFX 8u40
  • Method Details

    • getTabs

      public final ObservableList<Tab> getTabs()
      The tabs to display in this TabPane. Changing this ObservableList will immediately result in the TabPane updating to display the new contents of this ObservableList.

      If the tabs ObservableList changes, the selected tab will remain the previously selected tab, if it remains within this ObservableList. If the previously selected tab is no longer in the tabs ObservableList, the selected tab will become the first tab in the ObservableList.

      Returns:
      the list of tabs
    • setSelectionModel

      public final void setSelectionModel(SingleSelectionModel<Tab> value)
      Sets the value of the property selectionModel.
      Property description:
      The selection model used for selecting tabs. Changing the model alters how the tabs are selected and which tabs are first or last.
    • getSelectionModel

      public final SingleSelectionModel<Tab> getSelectionModel()
      Gets the value of the property selectionModel.
      Property description:
      The selection model used for selecting tabs. Changing the model alters how the tabs are selected and which tabs are first or last.
    • selectionModelProperty

      public final ObjectProperty<SingleSelectionModel<Tab>> selectionModelProperty()
      The selection model used for selecting tabs. Changing the model alters how the tabs are selected and which tabs are first or last.
      See Also:
    • setSide

      public final void setSide(Side value)
      Sets the value of the property side.
      Property description:
      The position to place the tabs in this TabPane. Changes to the value of this property immediately updates the location of the tabs.
      Default value:
      Side.Top
    • getSide

      public final Side getSide()
      Gets the value of the property side.
      Property description:
      The position to place the tabs in this TabPane. Changes to the value of this property immediately updates the location of the tabs.
      Default value:
      Side.Top
    • sideProperty

      public final ObjectProperty<Side> sideProperty()
      The position to place the tabs in this TabPane. Changes to the value of this property immediately updates the location of the tabs.
      Default value:
      Side.Top
      See Also:
    • setTabClosingPolicy

      public final void setTabClosingPolicy(TabPane.TabClosingPolicy value)
      Sets the value of the property tabClosingPolicy.
      Property description:
      Specifies how the TabPane handles tab closing from an end-user's perspective.

      Refer to the TabPane.TabClosingPolicy enumeration for further details.

      Default value:
      TabClosingPolicy.SELECTED_TAB
    • getTabClosingPolicy

      public final TabPane.TabClosingPolicy getTabClosingPolicy()
      Gets the value of the property tabClosingPolicy.
      Property description:
      Specifies how the TabPane handles tab closing from an end-user's perspective.

      Refer to the TabPane.TabClosingPolicy enumeration for further details.

      Default value:
      TabClosingPolicy.SELECTED_TAB
    • tabClosingPolicyProperty

      public final ObjectProperty<TabPane.TabClosingPolicy> tabClosingPolicyProperty()
      Specifies how the TabPane handles tab closing from an end-user's perspective.

      Refer to the TabPane.TabClosingPolicy enumeration for further details.

      Default value:
      TabClosingPolicy.SELECTED_TAB
      See Also:
    • setRotateGraphic

      public final void setRotateGraphic(boolean value)
      Sets the value of the property rotateGraphic.
      Property description:
      Specifies whether the graphic inside a Tab is rotated or not, such that it is always upright, or rotated in the same way as the Tab text is.

      If the value is false, the graphic isn't rotated, resulting in it always appearing upright. If the value is true, the graphic is rotated with the Tab text.

      Default value:
      false
    • isRotateGraphic

      public final boolean isRotateGraphic()
      Gets the value of the property rotateGraphic.
      Property description:
      Specifies whether the graphic inside a Tab is rotated or not, such that it is always upright, or rotated in the same way as the Tab text is.

      If the value is false, the graphic isn't rotated, resulting in it always appearing upright. If the value is true, the graphic is rotated with the Tab text.

      Default value:
      false
    • rotateGraphicProperty

      public final BooleanProperty rotateGraphicProperty()
      Specifies whether the graphic inside a Tab is rotated or not, such that it is always upright, or rotated in the same way as the Tab text is.

      If the value is false, the graphic isn't rotated, resulting in it always appearing upright. If the value is true, the graphic is rotated with the Tab text.

      Default value:
      false
      See Also:
    • setTabMinWidth

      public final void setTabMinWidth(double value)
      Sets the value of the property tabMinWidth.
      Property description:
      The minimum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-min-width.

      Default value:
      0
    • getTabMinWidth

      public final double getTabMinWidth()
      Gets the value of the property tabMinWidth.
      Property description:
      The minimum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-min-width.

      Default value:
      0
    • tabMinWidthProperty

      public final DoubleProperty tabMinWidthProperty()
      The minimum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-min-width.

      Default value:
      0
      See Also:
    • setTabMaxWidth

      public final void setTabMaxWidth(double value)
      Sets the value of the property tabMaxWidth.
      Property description:
      The maximum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. If the Tab text is longer than the maximum width, the text will be truncated. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-max-width.

      Default value:
      Double.MAX_VALUE
    • getTabMaxWidth

      public final double getTabMaxWidth()
      Gets the value of the property tabMaxWidth.
      Property description:
      The maximum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. If the Tab text is longer than the maximum width, the text will be truncated. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-max-width.

      Default value:
      Double.MAX_VALUE
    • tabMaxWidthProperty

      public final DoubleProperty tabMaxWidthProperty()
      The maximum width of a Tab in the TabPane. This can be used to limit the length of text in tabs to prevent truncation. If the Tab text is longer than the maximum width, the text will be truncated. Setting the same minimum and maximum widths will fix the width of the Tab.

      This value can also be set via CSS using -fx-tab-max-width.

      Default value:
      Double.MAX_VALUE
      See Also:
    • setTabMinHeight

      public final void setTabMinHeight(double value)
      Sets the value of the property tabMinHeight.
      Property description:
      The minimum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-min-height.

      Default value:
      0
    • getTabMinHeight

      public final double getTabMinHeight()
      Gets the value of the property tabMinHeight.
      Property description:
      The minimum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-min-height.

      Default value:
      0
    • tabMinHeightProperty

      public final DoubleProperty tabMinHeightProperty()
      The minimum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-min-height.

      Default value:
      0
      See Also:
    • setTabMaxHeight

      public final void setTabMaxHeight(double value)
      Sets the value of the property tabMaxHeight.
      Property description:
      The maximum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-max-height.

      Default value:
      Double.MAX_VALUE
    • getTabMaxHeight

      public final double getTabMaxHeight()
      Gets the value of the property tabMaxHeight.
      Property description:
      The maximum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-max-height.

      Default value:
      Double.MAX_VALUE
    • tabMaxHeightProperty

      public final DoubleProperty tabMaxHeightProperty()
      The maximum height of a Tab in the TabPane. This can be used to limit the height of tabs. Setting the same minimum and maximum heights will fix the height of the Tab.

      This value can also be set via CSS using -fx-tab-max-height.

      Default value:
      Double.MAX_VALUE
      See Also:
    • getClassCssMetaData

      public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
      Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
      Returns:
      the CssMetaData
      Since:
      JavaFX 8.0
    • getControlCssMetaData

      public List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
      Gets the unmodifiable list of the control's CSS-styleable properties.
      Overrides:
      getControlCssMetaData in class Control
      Returns:
      the unmodifiable list of the control's CSS-styleable properties
      Since:
      JavaFX 8.0
    • tabDragPolicyProperty

      public final ObjectProperty<TabPane.TabDragPolicy> tabDragPolicyProperty()
      The drag policy for the tabs. It specifies if tabs can be reordered or not.
      Default value:
      TabDragPolicy.FIXED
      Since:
      10
      See Also:
    • setTabDragPolicy

      public final void setTabDragPolicy(TabPane.TabDragPolicy value)
      Sets the value of the property tabDragPolicy.
      Property description:
      The drag policy for the tabs. It specifies if tabs can be reordered or not.
      Default value:
      TabDragPolicy.FIXED
      Since:
      10
    • getTabDragPolicy

      public final TabPane.TabDragPolicy getTabDragPolicy()
      Gets the value of the property tabDragPolicy.
      Property description:
      The drag policy for the tabs. It specifies if tabs can be reordered or not.
      Default value:
      TabDragPolicy.FIXED
      Since:
      10