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(200,200, Color.LIGHTSTEELBLUE));
tabPane.getTabs().add(tab);
Tab
Type | Property and Description |
---|---|
BooleanProperty |
rotateGraphic
The rotateGraphic state of the tabs in the TabPane.
|
<any> |
selectionModel
The selection model used for selecting tabs.
|
<any> |
side
The position of the tabs in the TabPane.
|
<any> |
tabClosingPolicy
The closing policy for the tabs.
|
<any> |
tabDragPolicy
The drag policy for the tabs.
|
DoubleProperty |
tabMaxHeight
The maximum height of the tabs in the TabPane.
|
DoubleProperty |
tabMaxWidth
The maximum width of the tabs in the TabPane.
|
DoubleProperty |
tabMinHeight
The minimum height of the tab.
|
DoubleProperty |
tabMinWidth
The minimum width of the tabs in the TabPane.
|
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
Modifier and Type | Class and Description |
---|---|
private static class |
TabPane.StyleableProperties
*
Stylesheet Handling *
*
|
static class |
TabPane.TabClosingPolicy
This specifies how the TabPane handles tab closing from an end-users
perspective.
|
static class |
TabPane.TabDragPolicy
This enum specifies drag policies for tabs in a TabPane.
|
(package private) static class |
TabPane.TabPaneSelectionModel
*
Support classes *
*
|
Modifier and Type | Field and Description |
---|---|
private static PseudoClass |
BOTTOM_PSEUDOCLASS_STATE |
private static double |
DEFAULT_TAB_MAX_HEIGHT |
private static double |
DEFAULT_TAB_MAX_WIDTH |
private static double |
DEFAULT_TAB_MIN_HEIGHT |
private static double |
DEFAULT_TAB_MIN_WIDTH |
private static PseudoClass |
LEFT_PSEUDOCLASS_STATE |
private static PseudoClass |
RIGHT_PSEUDOCLASS_STATE |
private BooleanProperty |
rotateGraphic |
private <any> |
selectionModel |
private <any> |
side |
static java.lang.String |
STYLE_CLASS_FLOATING
TabPane mode will be changed to floating allowing the TabPane
to be placed alongside other control.
|
private <any> |
tabClosingPolicy |
private <any> |
tabDragPolicy |
private DoubleProperty |
tabMaxHeight
The maximum height if the tabs in the TabPane.
|
private DoubleProperty |
tabMaxWidth
Specifies the maximum width of a tab.
|
private DoubleProperty |
tabMinHeight |
private DoubleProperty |
tabMinWidth |
private <any> |
tabs |
private static PseudoClass |
TOP_PSEUDOCLASS_STATE |
Constructor and Description |
---|
TabPane()
Constructs a new TabPane.
|
TabPane(Tab... tabs)
Constructs a new TabPane with the given tabs set to show.
|
Modifier and Type | Method and Description |
---|---|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
static java.util.List<<any>> |
getClassCssMetaData() |
java.util.List<<any>> |
getControlCssMetaData() |
SingleSelectionModel<Tab> |
getSelectionModel()
Gets the model used for tab selection.
|
Side |
getSide()
The current position of the tabs in the TabPane.
|
TabPane.TabClosingPolicy |
getTabClosingPolicy()
The closing policy for the tabs.
|
TabPane.TabDragPolicy |
getTabDragPolicy()
Gets the value of the property tabDragPolicy.
|
double |
getTabMaxHeight()
The maximum height of the tabs in the TabPane.
|
double |
getTabMaxWidth()
The maximum width of the tabs in the TabPane.
|
double |
getTabMinHeight()
The minimum height of the tabs in the TabPane.
|
double |
getTabMinWidth()
The minimum width of the tabs in the TabPane.
|
<any> |
getTabs()
The tabs to display in this TabPane.
|
boolean |
isRotateGraphic()
Returns
true if the graphic inside a Tab is rotated. |
Node |
lookup(java.lang.String selector) |
java.util.Set<Node> |
lookupAll(java.lang.String selector) |
BooleanProperty |
rotateGraphicProperty()
The rotateGraphic state of the tabs in the TabPane.
|
<any> |
selectionModelProperty()
The selection model used for selecting tabs.
|
void |
setRotateGraphic(boolean value)
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.
|
void |
setSelectionModel(SingleSelectionModel<Tab> value)
Sets the model used for tab selection.
|
void |
setSide(Side value)
The position to place the tabs in this TabPane.
|
void |
setTabClosingPolicy(TabPane.TabClosingPolicy value)
Specifies how the TabPane handles tab closing from an end-users
perspective.
|
void |
setTabDragPolicy(TabPane.TabDragPolicy value)
Sets the value of the property tabDragPolicy.
|
void |
setTabMaxHeight(double value)
Sets the value of the property tabMaxHeight.
|
void |
setTabMaxWidth(double value)
Sets the value of the property tabMaxWidth.
|
void |
setTabMinHeight(double value)
The minimum height of the tabs in the TabPane.
|
void |
setTabMinWidth(double value)
The minimum width of the tabs in the TabPane.
|
<any> |
sideProperty()
The position of the tabs in the TabPane.
|
<any> |
tabClosingPolicyProperty()
The closing policy for the tabs.
|
<any> |
tabDragPolicyProperty()
The drag policy for the tabs.
|
DoubleProperty |
tabMaxHeightProperty()
The maximum height of the tabs in the TabPane.
|
DoubleProperty |
tabMaxWidthProperty()
The maximum width of the tabs in the TabPane.
|
DoubleProperty |
tabMinHeightProperty()
The minimum height of the tab.
|
DoubleProperty |
tabMinWidthProperty()
The minimum width of the tabs in the TabPane.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getControlChildren, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, loadSkinClass, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
public final <any> selectionModelProperty
public final <any> sideProperty
getSide()
,
setSide(Side)
public final <any> tabClosingPolicyProperty
public final BooleanProperty rotateGraphicProperty
isRotateGraphic()
,
setRotateGraphic(boolean)
public final DoubleProperty tabMinWidthProperty
getTabMinWidth()
,
setTabMinWidth(double)
public final DoubleProperty tabMaxWidthProperty
public final DoubleProperty tabMinHeightProperty
getTabMinHeight()
,
setTabMinHeight(double)
public final DoubleProperty tabMaxHeightProperty
The maximum height of the tabs in the TabPane.
public final <any> tabDragPolicyProperty
getTabDragPolicy()
,
setTabDragPolicy(TabDragPolicy)
private static final double DEFAULT_TAB_MIN_WIDTH
private static final double DEFAULT_TAB_MAX_WIDTH
private static final double DEFAULT_TAB_MIN_HEIGHT
private static final double DEFAULT_TAB_MAX_HEIGHT
public static final java.lang.String STYLE_CLASS_FLOATING
private <any> tabs
private <any> selectionModel
private <any> side
private <any> tabClosingPolicy
private BooleanProperty rotateGraphic
private DoubleProperty tabMinWidth
private DoubleProperty tabMaxWidth
Specifies the maximum width of a tab. This can be used to limit
the length of text in tabs. If the tab text is longer than the maximum
width the text will be truncated. Setting the max equal
to the min will fix the width of the tab. By default the min equals to the max
This value can also be set via CSS using -fx-tab-max-width
.
private DoubleProperty tabMinHeight
private DoubleProperty tabMaxHeight
The maximum height if the tabs in the TabPane. This can be used to limit the height in tabs. Setting the max equal to the min will fix the height of the tab. By default the min equals to the max. This value can also be set via CSS using -fx-tab-max-height
private static final PseudoClass TOP_PSEUDOCLASS_STATE
private static final PseudoClass BOTTOM_PSEUDOCLASS_STATE
private static final PseudoClass LEFT_PSEUDOCLASS_STATE
private static final PseudoClass RIGHT_PSEUDOCLASS_STATE
private <any> tabDragPolicy
public final <any> 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.
public final void setSelectionModel(SingleSelectionModel<Tab> value)
Sets the model used for tab selection. By changing the model you can alter how the tabs are selected and which tabs are first or last.
value
- the selection modelpublic final SingleSelectionModel<Tab> getSelectionModel()
Gets the model used for tab selection.
public final <any> selectionModelProperty()
public final void setSide(Side value)
The position to place the tabs in this TabPane. Whenever this changes the TabPane will immediately update the location of the tabs to reflect this.
value
- the sidepublic final Side getSide()
public final <any> sideProperty()
getSide()
,
setSide(Side)
public final void setTabClosingPolicy(TabPane.TabClosingPolicy value)
Specifies how the TabPane handles tab closing from an end-users perspective. The options are:
Refer to the TabPane.TabClosingPolicy
enumeration for further details.
value
- the closing policypublic final TabPane.TabClosingPolicy getTabClosingPolicy()
public final <any> tabClosingPolicyProperty()
public final void setRotateGraphic(boolean value)
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.
By default rotateGraphic is set to false, to represent the fact that
the graphic isn't rotated, resulting in it always appearing upright. If
rotateGraphic is set to true
, the graphic will rotate such that it
rotates with the tab text.
value
- a flag indicating whether to rotate the graphicpublic final boolean isRotateGraphic()
true
if the graphic inside a Tab is rotated. The
default is false
public final BooleanProperty rotateGraphicProperty()
isRotateGraphic()
,
setRotateGraphic(boolean)
public final void setTabMinWidth(double value)
The minimum width of the tabs in the TabPane. This can be used to limit
the length of text in tabs to prevent truncation. Setting the min equal
to the max will fix the width of the tab. By default the min equals to the max.
This value can also be set via CSS using -fx-tab-min-width
value
- the minimum width of the tabspublic final double getTabMinWidth()
public final DoubleProperty tabMinWidthProperty()
getTabMinWidth()
,
setTabMinWidth(double)
public final void setTabMaxWidth(double value)
public final double getTabMaxWidth()
public final DoubleProperty tabMaxWidthProperty()
public final void setTabMinHeight(double value)
The minimum height of the tabs in the TabPane. This can be used to limit
the height in tabs. Setting the min equal to the max will fix the height
of the tab. By default the min equals to the max.
This value can also be set via CSS using -fx-tab-min-height
value
- the minimum height of the tabspublic final double getTabMinHeight()
public final DoubleProperty tabMinHeightProperty()
getTabMinHeight()
,
setTabMinHeight(double)
public final void setTabMaxHeight(double value)
public final double getTabMaxHeight()
public final DoubleProperty tabMaxHeightProperty()
The maximum height of the tabs in the TabPane.
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class Control
public Node lookup(java.lang.String selector)
public java.util.Set<Node> lookupAll(java.lang.String selector)
public static java.util.List<<any>> getClassCssMetaData()
public java.util.List<<any>> getControlCssMetaData()
getControlCssMetaData
in class Control
public final <any> tabDragPolicyProperty()
getTabDragPolicy()
,
setTabDragPolicy(TabDragPolicy)
public final void setTabDragPolicy(TabPane.TabDragPolicy value)
public final TabPane.TabDragPolicy getTabDragPolicy()