Class Tab
- All Implemented Interfaces:
Styleable
,EventTarget
Tabs are placed within a TabPane
, where each tab represents a single
'page'.
Tabs can contain any Node
such as UI controls or groups
of nodes added to a layout container.
When the user clicks on a Tab in the TabPane the Tab content becomes visible to the user.
- Since:
- JavaFX 2.0
-
Property Summary
TypePropertyDescriptionfinal BooleanProperty
The closable state for this tab.final ObjectProperty<Node>
The content associated with the tab.final ReadOnlyBooleanProperty
Indicates whether or not thisTab
is disabled.final BooleanProperty
Sets the disabled state of this tab.final ObjectProperty<Node>
The graphic in the tab.final StringProperty
The id of this tab.final ObjectProperty<EventHandler<Event>>
The event handler that is associated with the tab when the tab is closed.final ObjectProperty<EventHandler<Event>>
Called when there is an external request to close thisTab
.final ObjectProperty<EventHandler<Event>>
The event handler that is associated with a selection on the tab.final ReadOnlyBooleanProperty
The currently selected tab.final StringProperty
The CSS style string associated to this tab.final ReadOnlyObjectProperty<TabPane>
The TabPane that contains this tab.final StringProperty
The text shown in the tab. -
Field Summary
Modifier and TypeFieldDescriptionCalled when a user closes this tab.Called when the tab becomes selected or unselected.Called when there is an external request to close thisTab
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal BooleanProperty
The closable state for this tab.final ObjectProperty<Node>
The content associated with the tab.final ReadOnlyBooleanProperty
Indicates whether or not thisTab
is disabled.final BooleanProperty
Sets the disabled state of this tab.final Node
The content associated with the tab.final Node
The graphic shown in the tab.final String
getId()
The id of this tab.final EventHandler<Event>
The event handler that is associated with the tab when the tab is closed.Gets the value of theonCloseRequest
property.final EventHandler<Event>
The event handler that is associated with a selection on the tab.final ObservableMap<Object,
Object> Returns an observable map of properties on this Tab for use primarily by application developers.final String
getStyle()
The CSS style string associated to this tab.A list of String identifiers which can be used to logically group Nodes, specifically for an external style engine.final TabPane
A reference to the TabPane that contains this tab instance.final String
getText()
The text shown in the tab.Returns a previously set Object property, or null if no such property has been set using thesetUserData(java.lang.Object)
method.final ObjectProperty<Node>
The graphic in the tab.boolean
Tests if this Tab has properties.final StringProperty
The id of this tab.final boolean
Returnstrue
if this tab is closable.final boolean
Returnstrue
if this tab is disable.final boolean
final boolean
Represents whether this tab is the currently selected tab, To change the selected Tab usetabPane.getSelectionModel().select()
final ObjectProperty<EventHandler<Event>>
The event handler that is associated with the tab when the tab is closed.final ObjectProperty<EventHandler<Event>>
Called when there is an external request to close thisTab
.final ObjectProperty<EventHandler<Event>>
The event handler that is associated with a selection on the tab.final ReadOnlyBooleanProperty
The currently selected tab.final void
setClosable
(boolean value) Setstrue
if the tab is closable.final void
setContent
(Node value) The content to show within the main TabPane area.final void
setDisable
(boolean value) Sets the disabled state of this tab.final void
setGraphic
(Node value) Sets the graphic to show in the tab to allow the user to differentiate between the function of each tab.final void
Sets the id of this tab.final void
setOnClosed
(EventHandler<Event> value) Defines a function to be called when the tab is closed.void
setOnCloseRequest
(EventHandler<Event> value) Sets the value of theonCloseRequest
property.final void
setOnSelectionChanged
(EventHandler<Event> value) Defines a function to be called when a selection changed has occurred on the tab.final void
A string representation of the CSS style associated with this tab.final void
Sets the text to show in the tab to allow the user to differentiate between the function of each tab.void
setUserData
(Object value) Convenience method for setting a single Object property that can be retrieved at a later date.final StringProperty
The CSS style string associated to this tab.final ReadOnlyObjectProperty<TabPane>
The TabPane that contains this tab.final StringProperty
The text shown in the tab.
-
Property Details
-
id
The id of this tab.- See Also:
-
style
The CSS style string associated to this tab.- See Also:
-
selected
The currently selected tab.- See Also:
-
tabPane
The TabPane that contains this tab.- See Also:
-
text
The text shown in the tab.- See Also:
-
graphic
The graphic in the tab.- See Also:
-
content
The content associated with the tab.
- See Also:
-
closable
The closable state for this tab.- See Also:
-
onSelectionChanged
The event handler that is associated with a selection on the tab. -
onClosed
The event handler that is associated with the tab when the tab is closed. -
disable
Sets the disabled state of this tab. A disable tab is no longer interactive or traversable, but the contents remain interactive. A disable tab can be selected usingTabPane.getSelectionModel()
.- Default value:
- false
- Since:
- JavaFX 2.2
- See Also:
-
disabled
Indicates whether or not thisTab
is disabled. ATab
will become disabled ifdisable
is set totrue
on either itself or if theTabPane
is disabled.- Default value:
- false
- Since:
- JavaFX 2.2
- See Also:
-
onCloseRequest
Called when there is an external request to close thisTab
. The installed event handler can prevent tab closing by consuming the received event.- Since:
- JavaFX 8.0
- See Also:
-
-
Field Details
-
SELECTION_CHANGED_EVENT
Called when the tab becomes selected or unselected.
-
CLOSED_EVENT
Called when a user closes this tab. This is useful for freeing up memory.
-
TAB_CLOSE_REQUEST_EVENT
Called when there is an external request to close thisTab
. The installed event handler can prevent tab closing by consuming the received event.- Since:
- JavaFX 8.0
-
-
Constructor Details
-
Tab
public Tab()Creates a tab with no title. -
Tab
Creates a tab with a text title.- Parameters:
text
- The title of the tab.
-
Tab
Creates a tab with a text title and the specified content node.- Parameters:
text
- The title of the tab.content
- The content of the tab.- Since:
- JavaFX 8u40
-
-
Method Details
-
setId
Sets the id of this tab. This simple string identifier is useful for finding a specific Tab within theTabPane
. The default value isnull
. -
getId
The id of this tab. -
idProperty
The id of this tab. -
setStyle
A string representation of the CSS style associated with this tab. This is analogous to the "style" attribute of an HTML element. Note that, like the HTML style attribute, this variable contains style properties and values and not the selector portion of a style rule.Parsing this style might not be supported on some limited platforms. It is recommended to use a standalone CSS file instead.
-
getStyle
The CSS style string associated to this tab. -
styleProperty
The CSS style string associated to this tab.- Returns:
- the
style
property - See Also:
-
isSelected
public final boolean isSelected()Represents whether this tab is the currently selected tab, To change the selected Tab use
tabPane.getSelectionModel().select()
-
selectedProperty
The currently selected tab.- Returns:
- the
selected
property - See Also:
-
getTabPane
A reference to the TabPane that contains this tab instance.
-
tabPaneProperty
The TabPane that contains this tab.- Returns:
- the
tabPane
property - See Also:
-
setText
Sets the text to show in the tab to allow the user to differentiate between the function of each tab. The text is always visible
-
getText
The text shown in the tab.- Returns:
- The text shown in the tab.
-
textProperty
The text shown in the tab.- Returns:
- the
text
property - See Also:
-
setGraphic
Sets the graphic to show in the tab to allow the user to differentiate between the function of each tab. By default the graphic does not rotate based on the TabPane.tabPosition value, but it can be set to rotate by setting TabPane.rotateGraphic to true.
-
getGraphic
The graphic shown in the tab.- Returns:
- The graphic shown in the tab.
-
graphicProperty
The graphic in the tab.- Returns:
- The graphic in the tab.
- See Also:
-
setContent
The content to show within the main TabPane area. The content can be any Node such as UI controls or groups of nodes added to a layout container.
-
getContent
The content associated with the tab.
- Returns:
- The content associated with the tab.
-
contentProperty
The content associated with the tab.
- Returns:
- the
content
property - See Also:
-
setClosable
public final void setClosable(boolean value) Sets
true
if the tab is closable. If this is set tofalse
, then regardless of the TabClosingPolicy, it will not be possible for the user to close this tab. Therefore, when this property isfalse
, no 'close' button will be shown on the tab. The default istrue
. -
isClosable
public final boolean isClosable()Returnstrue
if this tab is closable.- Returns:
true
if the tab is closable.
-
closableProperty
The closable state for this tab. -
setOnSelectionChanged
Defines a function to be called when a selection changed has occurred on the tab. -
getOnSelectionChanged
The event handler that is associated with a selection on the tab.- Returns:
- The event handler that is associated with a tab selection.
-
onSelectionChangedProperty
The event handler that is associated with a selection on the tab.- Returns:
- the
onSelectionChanged
property - See Also:
-
setOnClosed
Defines a function to be called when the tab is closed. -
getOnClosed
The event handler that is associated with the tab when the tab is closed.- Returns:
- The event handler that is associated with the tab when the tab is closed.
-
onClosedProperty
The event handler that is associated with the tab when the tab is closed.- Returns:
- the
onClosed
property - See Also:
-
setDisable
public final void setDisable(boolean value) Sets the disabled state of this tab.- Default value:
- false
- Parameters:
value
- the state to set this tab- Since:
- JavaFX 2.2
-
isDisable
public final boolean isDisable()Returnstrue
if this tab is disable.- Since:
- JavaFX 2.2
-
disableProperty
Sets the disabled state of this tab. A disable tab is no longer interactive or traversable, but the contents remain interactive. A disable tab can be selected usingTabPane.getSelectionModel()
.- Default value:
- false
- Returns:
- the
disable
property - Since:
- JavaFX 2.2
- See Also:
-
isDisabled
public final boolean isDisabled()- Since:
- JavaFX 2.2
-
disabledProperty
Indicates whether or not thisTab
is disabled. ATab
will become disabled ifdisable
is set totrue
on either itself or if theTabPane
is disabled.- Default value:
- false
- Returns:
- the
disabled
property - Since:
- JavaFX 2.2
- See Also:
-
onCloseRequestProperty
Called when there is an external request to close thisTab
. The installed event handler can prevent tab closing by consuming the received event.- Returns:
- the
onCloseRequest
property - Since:
- JavaFX 8.0
- See Also:
-
getOnCloseRequest
Gets the value of theonCloseRequest
property.- Property description:
- Called when there is an external request to close this
Tab
. The installed event handler can prevent tab closing by consuming the received event. - Returns:
- the value of the
onCloseRequest
property - Since:
- JavaFX 8.0
- See Also:
-
setOnCloseRequest
Sets the value of theonCloseRequest
property.- Property description:
- Called when there is an external request to close this
Tab
. The installed event handler can prevent tab closing by consuming the received event. - Parameters:
value
- the value for theonCloseRequest
property- Since:
- JavaFX 8.0
- See Also:
-
getProperties
Returns an observable map of properties on this Tab for use primarily by application developers.- Returns:
- an observable map of properties on this Tab for use primarily by application developers
- Since:
- JavaFX 2.2
-
hasProperties
public boolean hasProperties()Tests if this Tab has properties.- Returns:
- true if this tab has properties.
- Since:
- JavaFX 2.2
-
setUserData
Convenience method for setting a single Object property that can be retrieved at a later date. This is functionally equivalent to calling the getProperties().put(Object key, Object value) method. This can later be retrieved by callinggetUserData()
.- Parameters:
value
- The value to be stored - this can later be retrieved by callinggetUserData()
.- Since:
- JavaFX 2.2
-
getUserData
Returns a previously set Object property, or null if no such property has been set using thesetUserData(java.lang.Object)
method.- Returns:
- The Object that was previously set, or null if no property has been set or if null was set.
- Since:
- JavaFX 2.2
-
getStyleClass
A list of String identifiers which can be used to logically group Nodes, specifically for an external style engine. This variable is analogous to the "class" attribute on an HTML element and, as such, each element of the list is a style class to which this Node belongs.- Specified by:
getStyleClass
in interfaceStyleable
- See Also:
-