APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.control

public Class TabPane

extends Control
Class Inheritance
Annotations
@DefaultProperty:tabs
Imports
java.util.ArrayList, .Collections, .List, .Set, com.sun.javafx.collections.UnmodifiableListSet, com.sun.javafx.scene.control.TabObservableList, javafx.beans.property.BooleanProperty, .DoubleProperty, .ObjectProperty, .ObjectPropertyBase, .SimpleBooleanProperty, .SimpleObjectProperty, javafx.collections.ListChangeListener, .ObservableList, .WeakListChangeListener, javafx.geometry.Side, javafx.scene.AccessibleAttribute, .AccessibleRole, .Node, javafx.css.StyleableDoubleProperty, .CssMetaData, .PseudoClass, .Styleable, .StyleableProperty, javafx.css.converter.SizeConverter, javafx.scene.control.skin.TabPaneSkin, javafx.beans.DefaultProperty

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
Tab

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static enum
TabPane.TabClosingPolicy

Specifies how the TabPane handles tab closing from an end-user's perspective.

public static enum
TabPane.TabDragPolicy

This enum specifies drag policies for tabs in a TabPane.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final PseudoClass
private static final double
private static final double
private static final double
private static final double
private static final PseudoClass
private static final PseudoClass
private BooleanProperty
rotateGraphic

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.

private ObjectProperty<SingleSelectionModel<Tab>>
selectionModel

The selection model used for selecting tabs.

private ObjectProperty<Side>
side

The position to place the tabs in this TabPane.

public static final String
STYLE_CLASS_FLOATING

TabPane mode will be changed to floating allowing the TabPane to be placed alongside other control.

private ObjectProperty<TabPane.TabClosingPolicy>
tabClosingPolicy

Specifies how the TabPane handles tab closing from an end-user's perspective.

private ObjectProperty<TabPane.TabDragPolicy>
tabDragPolicy

The drag policy for the tabs.

private DoubleProperty
tabMaxHeight

The maximum height of a Tab in the TabPane.

private DoubleProperty
tabMaxWidth

The maximum width of a Tab in the TabPane.

private DoubleProperty
tabMinHeight

The minimum height of a Tab in the TabPane.

private DoubleProperty
tabMinWidth

The minimum width of a Tab in the TabPane.

private ObservableList<Tab>
private static final PseudoClass

Constructor Summary

AccessConstructor and Description
public
TabPane()

Constructs a new TabPane.

public
TabPane(Tab...
The tabs to display inside the TabPane.
tabs
)

Constructs a new TabPane with the given tabs set to show.

Method Summary

Modifier and TypeMethod and Description
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

public final SingleSelectionModel<Tab>
public final Side
public final TabPane.TabClosingPolicy
public final TabPane.TabDragPolicy
public final double
public final double
public final double
public final double
public final ObservableList<Tab>

Returns:

the list of tabs
getTabs
()

The tabs to display in this TabPane.

public final boolean
public Node
lookup(String selector)

Overrides javafx.scene.Parent.lookup.

Finds this Node, or the first sub-node, based on the given CSS selector.

public Set<Node>
lookupAll(String selector)

Overrides javafx.scene.Node.lookupAll.

Finds all Nodes, including this one and any children, which match the given CSS selector.

public final BooleanProperty
public final ObjectProperty<SingleSelectionModel<Tab>>
public final void
setRotateGraphic(boolean value)

public final void
public final void
setSide(Side value)

public final void
public final void
public final void
setTabMaxHeight(double value)

public final void
setTabMaxWidth(double value)

public final void
setTabMinHeight(double value)

public final void
setTabMinWidth(double value)

public final ObjectProperty<Side>
public final ObjectProperty<TabPane.TabClosingPolicy>
public final ObjectProperty<TabPane.TabDragPolicy>
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetContextMenugetControlChildrengetCssMetaDatagetInitialFocusTraversablegetSkingetTooltipisResizablelayoutChildrenloadSkinClassqueryAccessibleAttributesetContextMenusetSkinsetTooltipskinClassNamePropertyskinPropertytooltipProperty

Field Detail

BOTTOM_PSEUDOCLASS_STATEback to summary
private static final PseudoClass BOTTOM_PSEUDOCLASS_STATE
DEFAULT_TAB_MAX_HEIGHTback to summary
private static final double DEFAULT_TAB_MAX_HEIGHT
DEFAULT_TAB_MAX_WIDTHback to summary
private static final double DEFAULT_TAB_MAX_WIDTH
DEFAULT_TAB_MIN_HEIGHTback to summary
private static final double DEFAULT_TAB_MIN_HEIGHT
DEFAULT_TAB_MIN_WIDTHback to summary
private static final double DEFAULT_TAB_MIN_WIDTH
LEFT_PSEUDOCLASS_STATEback to summary
private static final PseudoClass LEFT_PSEUDOCLASS_STATE
RIGHT_PSEUDOCLASS_STATEback to summary
private static final PseudoClass RIGHT_PSEUDOCLASS_STATE
rotateGraphicback to summary
private BooleanProperty rotateGraphic

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
selectionModelback to summary
private ObjectProperty<SingleSelectionModel<Tab>> selectionModel

The selection model used for selecting tabs. Changing the model alters how the tabs are selected and which tabs are first or last.

sideback to summary
private ObjectProperty<Side> side

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
STYLE_CLASS_FLOATINGback to summary
public static final String STYLE_CLASS_FLOATING

TabPane mode will be changed to floating allowing the TabPane to be placed alongside other control.

tabClosingPolicyback to summary
private ObjectProperty<TabPane.TabClosingPolicy> tabClosingPolicy

Specifies how the TabPane handles tab closing from an end-user's perspective.

Refer to the TabClosingPolicy enumeration for further details.

Default Value
TabClosingPolicy.SELECTED_TAB
tabDragPolicyback to summary
private ObjectProperty<TabPane.TabDragPolicy> tabDragPolicy

The drag policy for the tabs. It specifies if tabs can be reordered or not.

Default Value
TabDragPolicy.FIXED
Since
10
tabMaxHeightback to summary
private DoubleProperty tabMaxHeight

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
tabMaxWidthback to summary
private DoubleProperty tabMaxWidth

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
tabMinHeightback to summary
private DoubleProperty tabMinHeight

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
tabMinWidthback to summary
private DoubleProperty tabMinWidth

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
tabsback to summary
private ObservableList<Tab> tabs
TOP_PSEUDOCLASS_STATEback to summary
private static final PseudoClass TOP_PSEUDOCLASS_STATE

Constructor Detail

TabPaneback to summary
public TabPane()

Constructs a new TabPane.

TabPaneback to summary
public TabPane(Tab... tabs)

Constructs a new TabPane with the given tabs set to show.

Parameters
tabs:Tab[]

The tabs to display inside the TabPane.

Since
JavaFX 8u40

Method Detail

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getControlCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Doc from javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

Annotations
@Override
Since
JavaFX 8.0
getSelectionModelback to summary
public final SingleSelectionModel<Tab> getSelectionModel()
getSideback to summary
public final Side getSide()
getTabClosingPolicyback to summary
public final TabPane.TabClosingPolicy getTabClosingPolicy()
getTabDragPolicyback to summary
public final TabPane.TabDragPolicy getTabDragPolicy()
getTabMaxHeightback to summary
public final double getTabMaxHeight()
getTabMaxWidthback to summary
public final double getTabMaxWidth()
getTabMinHeightback to summary
public final double getTabMinHeight()
getTabMinWidthback to summary
public final double getTabMinWidth()
getTabsback to summary
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:ObservableList<Tab>

the list of tabs

isRotateGraphicback to summary
public final boolean isRotateGraphic()
lookupback to summary
public Node lookup(String selector)

Overrides javafx.scene.Parent.lookup.

Doc from javafx.scene.Node.lookup.

Finds this Node, or the first sub-node, based on the given CSS selector. If this node is a Parent, then this function will traverse down into the branch until it finds a match. If more than one sub-node matches the specified selector, this function returns the first of them.

If the lookup selector does not specify a pseudo class, the lookup will ignore pseudo class states; it will return the first matching node whether or not it contains pseudo classes.

For example, if a Node is given the id of "myId", then the lookup method can be used to find this node as follows: scene.lookup("#myId");.

For example, if two nodes, NodeA and NodeB, have the same style class "myStyle" and NodeA has a pseudo state "myPseudo", then to find NodeA, the lookup method can be used as follows: scene.lookup(".myStyle:myPseudo"); or scene.lookup(":myPseudo");.

Annotations
@Override
lookupAllback to summary
public Set<Node> lookupAll(String selector)

Overrides javafx.scene.Node.lookupAll.

Doc from javafx.scene.Node.lookupAll.

Finds all Nodes, including this one and any children, which match the given CSS selector. If no matches are found, an empty unmodifiable set is returned. The set is explicitly unordered.

If the lookupAll selector does not specify a pseudo class, the lookupAll will ignore pseudo class states; it will return all matching nodes whether or not the nodes contain pseudo classes.

For example, if there are multiple nodes with same style class "myStyle", then the lookupAll method can be used to find all these nodes as follows: scene.lookupAll(".myStyle");.

For example, if multiple nodes have same style class "myStyle" and few nodes have a pseudo state "myPseudo", then to find all nodes with "myPseudo" state, the lookupAll method can be used as follows: scene.lookupAll(".myStyle:myPseudo"); or scene.lookupAll(":myPseudo");.

Annotations
@Override
rotateGraphicPropertyback to summary
public final BooleanProperty rotateGraphicProperty()
selectionModelPropertyback to summary
public final ObjectProperty<SingleSelectionModel<Tab>> selectionModelProperty()
setRotateGraphicback to summary
public final void setRotateGraphic(boolean value)
setSelectionModelback to summary
public final void setSelectionModel(SingleSelectionModel<Tab> value)
setSideback to summary
public final void setSide(Side value)
setTabClosingPolicyback to summary
public final void setTabClosingPolicy(TabPane.TabClosingPolicy value)
setTabDragPolicyback to summary
public final void setTabDragPolicy(TabPane.TabDragPolicy value)
setTabMaxHeightback to summary
public final void setTabMaxHeight(double value)
setTabMaxWidthback to summary
public final void setTabMaxWidth(double value)
setTabMinHeightback to summary
public final void setTabMinHeight(double value)
setTabMinWidthback to summary
public final void setTabMinWidth(double value)
sidePropertyback to summary
public final ObjectProperty<Side> sideProperty()
tabClosingPolicyPropertyback to summary
public final ObjectProperty<TabPane.TabClosingPolicy> tabClosingPolicyProperty()
tabDragPolicyPropertyback to summary
public final ObjectProperty<TabPane.TabDragPolicy> tabDragPolicyProperty()
tabMaxHeightPropertyback to summary
public final DoubleProperty tabMaxHeightProperty()
tabMaxWidthPropertyback to summary
public final DoubleProperty tabMaxWidthProperty()
tabMinHeightPropertyback to summary
public final DoubleProperty tabMinHeightProperty()
tabMinWidthPropertyback to summary
public final DoubleProperty tabMinWidthProperty()
javafx.scene.control back to summary

private Class TabPane.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final List<CssMetaData<? extends Styleable, ?>>
private static final CssMetaData<TabPane, Number>
private static final CssMetaData<TabPane, Number>
private static final CssMetaData<TabPane, Number>
private static final CssMetaData<TabPane, Number>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES
TAB_MAX_HEIGHTback to summary
private static final CssMetaData<TabPane, Number> TAB_MAX_HEIGHT
TAB_MAX_WIDTHback to summary
private static final CssMetaData<TabPane, Number> TAB_MAX_WIDTH
TAB_MIN_HEIGHTback to summary
private static final CssMetaData<TabPane, Number> TAB_MIN_HEIGHT
TAB_MIN_WIDTHback to summary
private static final CssMetaData<TabPane, Number> TAB_MIN_WIDTH

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()
javafx.scene.control back to summary

public final Enum TabPane.TabClosingPolicy

extends Enum<TabPane.TabClosingPolicy>
Class Inheritance

Specifies how the TabPane handles tab closing from an end-user's perspective. The options are:
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
public static final TabPane.TabClosingPolicy
ALL_TABS

All tabs will have the option to be closed.

public static final TabPane.TabClosingPolicy
SELECTED_TAB

Only the currently selected tab will have the option to be closed, with a graphic next to the tab text being shown.

public static final TabPane.TabClosingPolicy
UNAVAILABLE

Tabs can not be closed by the user.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TabPane.TabClosingPolicy
public static TabPane.TabClosingPolicy[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALL_TABSback to summary
public static final TabPane.TabClosingPolicy ALL_TABS

All tabs will have the option to be closed.

SELECTED_TABback to summary
public static final TabPane.TabClosingPolicy SELECTED_TAB

Only the currently selected tab will have the option to be closed, with a graphic next to the tab text being shown. The graphic will disappear when a tab is no longer selected.

UNAVAILABLEback to summary
public static final TabPane.TabClosingPolicy UNAVAILABLE

Tabs can not be closed by the user.

Constructor Detail

TabClosingPolicyback to summary
private TabClosingPolicy()

Method Detail

valueOfback to summary
public static TabPane.TabClosingPolicy valueOf(String name)
valuesback to summary
public static TabPane.TabClosingPolicy[] values()
javafx.scene.control back to summary

public final Enum TabPane.TabDragPolicy

extends Enum<TabPane.TabDragPolicy>
Class Inheritance

This enum specifies drag policies for tabs in a TabPane.
Since
10

Field Summary

Modifier and TypeField and Description
public static final TabPane.TabDragPolicy
FIXED

The tabs remain fixed in their positions and cannot be dragged.

public static final TabPane.TabDragPolicy
REORDER

The tabs can be dragged to reorder them within the same TabPane.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static TabPane.TabDragPolicy
public static TabPane.TabDragPolicy[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FIXEDback to summary
public static final TabPane.TabDragPolicy FIXED

The tabs remain fixed in their positions and cannot be dragged.

REORDERback to summary
public static final TabPane.TabDragPolicy REORDER

The tabs can be dragged to reorder them within the same TabPane. Users can perform the simple mouse press-drag-release gesture on a tab header to drag it to a new position. A tab can not be detached from its parent TabPane.

After a tab is reordered, the tabs list is permuted to reflect the updated order. A permutation change event is fired to indicate which tabs were reordered. This reordering is done after the mouse button is released. While a tab is being dragged, the list of tabs is unchanged.

Constructor Detail

TabDragPolicyback to summary
private TabDragPolicy()

Method Detail

valueOfback to summary
public static TabPane.TabDragPolicy valueOf(String name)
valuesback to summary
public static TabPane.TabDragPolicy[] values()
javafx.scene.control back to summary

pack-priv Class TabPane.TabPaneSelectionModel

extends SingleSelectionModel<Tab>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private ListChangeListener<Tab>
private final TabPane

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Tab
findNearestAvailableTab(int tabIndex, boolean doSelect)

protected int
getItemCount()

Implements abstract javafx.scene.control.SingleSelectionModel.getItemCount.

Gets the number of items available for the selection model.

protected Tab
getModelItem(int index)

Implements abstract javafx.scene.control.SingleSelectionModel.getModelItem.

Gets the data model item associated with a specific index.

public void
public void
select(Tab tab)

Overrides javafx.scene.control.SingleSelectionModel.select.

Selects the index for the first instance of given object in the underlying data model.

Inherited from javafx.scene.control.SingleSelectionModel:
clearAndSelectclearSelectionclearSelectionisEmptyisSelectedselectFirstselectLastselectNextselectPrevious

Field Detail

itemsContentObserverback to summary
private ListChangeListener<Tab> itemsContentObserver
tabPaneback to summary
private final TabPane tabPane

Constructor Detail

TabPaneSelectionModelback to summary
public TabPaneSelectionModel(final TabPane t)

Method Detail

findNearestAvailableTabback to summary
private Tab findNearestAvailableTab(int tabIndex, boolean doSelect)
getItemCountback to summary
protected int getItemCount()

Implements abstract javafx.scene.control.SingleSelectionModel.getItemCount.

Doc from javafx.scene.control.SingleSelectionModel.getItemCount.

Gets the number of items available for the selection model. If the number of items can change dynamically, it is the responsibility of the concrete SingleSelectionModel implementation to ensure that items are selected or unselected as appropriate as the items change.

Annotations
@Override
getModelItemback to summary
protected Tab getModelItem(int index)

Implements abstract javafx.scene.control.SingleSelectionModel.getModelItem.

Doc from javafx.scene.control.SingleSelectionModel.getModelItem.

Gets the data model item associated with a specific index.

Annotations
@Override
selectback to summary
public void select(int index)

Overrides javafx.scene.control.SingleSelectionModel.select, javafx.scene.control.SingleSelectionModel.select.

Doc from javafx.scene.control.SingleSelectionModel.select.

Selects the given index. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

Annotations
@Override
selectback to summary
public void select(Tab tab)

Overrides javafx.scene.control.SingleSelectionModel.select.

Doc from javafx.scene.control.SingleSelectionModel.select.

Selects the index for the first instance of given object in the underlying data model. Since the SingleSelectionModel can only support having a single index selected at a time, this also causes any previously selected index to be unselected.

Annotations
@Override