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

public Class ToolBar

extends Control
Class Inheritance
Annotations
@DefaultProperty:items
Imports
java.util.ArrayList, .Collections, .List, javafx.beans.DefaultProperty, javafx.beans.property.ObjectProperty, javafx.beans.value.WritableValue, javafx.collections.FXCollections, .ObservableList, javafx.geometry.Orientation, javafx.scene.AccessibleRole, .Node, javafx.css.StyleableObjectProperty, .CssMetaData, .PseudoClass, .Styleable, .StyleableProperty, javafx.css.converter.EnumConverter, javafx.scene.control.skin.ToolBarSkin

A ToolBar is a control which displays items horizontally or vertically. The most common items to place within a ToolBar are Buttons, ToggleButtons and Separators, but you are not restricted to just these, and can insert any Node into them.

If there are too many items to fit in the ToolBar an overflow button will appear. The overflow button allows you to select items that are not currently visible in the toolbar.

ToolBar sets focusTraversable to false.

Example of a horizontal ToolBar with eight buttons separated with two vertical separators.

 ToolBar toolBar = new ToolBar(
    new Button("New"),
    new Button("Open"),
    new Button("Save"),
    new Separator(),
    new Button("Clean"),
    new Button("Compile"),
    new Button("Run"),
    new Separator(),
    new Button("Debug"),
    new Button("Profile")
);
Image of the ToolBar control
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final PseudoClass
private final ObservableList<Node>
private ObjectProperty<Orientation>
orientation

The orientation of the ToolBar - this can either be horizontal or vertical.

private static final PseudoClass

Constructor Summary

AccessConstructor and Description
public
ToolBar()

Creates an empty tool bar.

public
ToolBar(Node...
the items to add
items
)

Creates a tool bar populated with the specified nodes.

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.

protected Boolean
getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value.

public final ObservableList<Node>

Returns:

the list of items
getItems
()

The items contained in the ToolBar.

public final Orientation
private void
public final ObjectProperty<Orientation>
public final void
Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetContextMenugetControlChildrengetCssMetaDatagetSkingetTooltipisResizablelayoutChildrenloadSkinClassqueryAccessibleAttributesetContextMenusetSkinsetTooltipskinClassNamePropertyskinPropertytooltipProperty

Field Detail

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS
HORIZONTAL_PSEUDOCLASS_STATEback to summary
private static final PseudoClass HORIZONTAL_PSEUDOCLASS_STATE
itemsback to summary
private final ObservableList<Node> items
orientationback to summary
private ObjectProperty<Orientation> orientation

The orientation of the ToolBar - this can either be horizontal or vertical.

VERTICAL_PSEUDOCLASS_STATEback to summary
private static final PseudoClass VERTICAL_PSEUDOCLASS_STATE

Constructor Detail

ToolBarback to summary
public ToolBar()

Creates an empty tool bar.

ToolBarback to summary
public ToolBar(Node... items)

Creates a tool bar populated with the specified nodes. None of the items can be null.

Parameters
items:Node[]

the items to add

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
getInitialFocusTraversableback to summary
protected Boolean getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden as by default UI controls have focus traversable set to true, but that is not appropriate for this control.

Annotations
@Override
Since
9
getItemsback to summary
public final ObservableList<Node> getItems()

The items contained in the ToolBar. Typical use case for a ToolBar suggest that the most common items to place within it are Buttons, ToggleButtons, and Separators, but you are not restricted to just these, and can insert any Node. The items added must not be null.

Returns:ObservableList<Node>

the list of items

getOrientationback to summary
public final Orientation getOrientation()
initializeback to summary
private void initialize()
orientationPropertyback to summary
public final ObjectProperty<Orientation> orientationProperty()
setOrientationback to summary
public final void setOrientation(Orientation value)
javafx.scene.control back to summary

private Class ToolBar.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<ToolBar, Orientation>
private static final List<CssMetaData<? extends Styleable, ?>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ORIENTATIONback to summary
private static final CssMetaData<ToolBar, Orientation> ORIENTATION
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()