Class ToolBar

All Implemented Interfaces:
Styleable, EventTarget, Skinnable

@DefaultProperty("items") public class ToolBar extends Control

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
  • Property Details

  • Constructor Details

    • ToolBar

      public ToolBar()
      Creates an empty tool bar.
    • ToolBar

      public ToolBar(Node... items)
      Creates a tool bar populated with the specified nodes. None of the items can be null.
      Parameters:
      items - the items to add
  • Method Details

    • getItems

      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:
      the list of items
    • setOrientation

      public final void setOrientation(Orientation value)
      Sets the value of the orientation property.
      Property description:
      The orientation of the ToolBar - this can either be horizontal or vertical.
      Parameters:
      value - the value for the orientation property
      See Also:
    • getOrientation

      public final Orientation getOrientation()
      Gets the value of the orientation property.
      Property description:
      The orientation of the ToolBar - this can either be horizontal or vertical.
      Returns:
      the value of the orientation property
      See Also:
    • orientationProperty

      public final ObjectProperty<Orientation> orientationProperty()
      The orientation of the ToolBar - this can either be horizontal or vertical.
      Returns:
      the orientation property
      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
    • getInitialFocusTraversable

      protected Boolean 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.
      Overrides:
      getInitialFocusTraversable in class Control
      Returns:
      the initial focus traversable state of this control
      Since:
      9