Top Description Fields Constructors Methods
com.dlsc.workbenchfx.view.controls

public final Class ToolbarItem

extends MenuButton
Class Inheritance
Imports
java.util.Objects, javafx.beans.InvalidationListener, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.collections.FXCollections, javafx.event.EventHandler, javafx.scene.Node, javafx.scene.control.Button, .Label, .MenuButton, .MenuItem, javafx.scene.image.ImageView, javafx.scene.input.MouseEvent, org.slf4j.Logger, .LoggerFactory

Represents the ToolbarItem which is used in the ToolbarControls of WorkbenchFX. Depending on the parameters defined in the constructor, the ToolbarItem changes its visual appearance to either a Label, a Button or a MenuButton. Using setGraphic(Node) offers additionally the possibility to add custom content. But doing this might require additional custom styling.
Authors
François Martin, Marco Sanfratello

Field Summary

Modifier and TypeField and Description
private static final double
ICON_RESIZING_FACTOR

Used to bind the fit size dimensions of an ImageView to this Controls pref height.

private static final double
ICON_SIZE

According to the material design standards, a desktop icon should have a size of 16x16px.

private static final Logger
private final ObjectProperty<EventHandler<? super MouseEvent>>
private static final String
TOOLBAR_BUTTON

The style class which is used to style the ToolbarItem as a Button.

private static final String
TOOLBAR_LABEL

The style class which is used to style the ToolbarItem as a Label.

private static final String
TOOLBAR_MENU_BUTTON

The style class which is used to style the ToolbarItem as a MenuButton.

private static final double
TOOLBAR_PADDING

The WorkbenchFX styles define a toolbar height of 40px with a padding of 3px on top and bottom.

private static final double
TOTAL_ICON_SIZE

The icon should be placed in a square of 40x40px as clearance.

Inherited from javafx.scene.control.MenuButton:
ON_HIDDENON_HIDINGON_SHOWINGON_SHOWN

Constructor Summary

AccessConstructor and Description
public
ToolbarItem()

Creates a new empty ToolbarItem.

public
ToolbarItem(String
to be displayed on the ToolbarItem
text
)

Creates a new ToolbarItem which appears like a Label, using the given text as label text.

public
ToolbarItem(Node
to be displayed on the ToolbarItem
graphic
)

Creates a new ToolbarItem which appears like a Label, using the given graphic as label graphic.

public
ToolbarItem(String
to be displayed on the ToolbarItem
text
,
Node
to be displayed on the ToolbarItem
graphic
)

Creates a new ToolbarItem which appears like a Label, using the given text and graphic as label content.

public
ToolbarItem(String
to be displayed on the ToolbarItem
text
,
EventHandler<? super MouseEvent>
the function to be called when a mouse button has been clicked (pressed and released) on this Control
onClick
)

Creates a new ToolbarItem which appears like a Button, using the given text as button text and the onClick as onMouseClicked event.

public
ToolbarItem(Node
the graphic to be displayed on the ToolbarItem
graphic
,
EventHandler<? super MouseEvent>
the function to be called when a mouse button has been clicked (pressed and released) on this Control
onClick
)

Creates a new ToolbarItem which appears like a Button, using the given graphic as button graphic and the onClick as onMouseClicked event.

public
ToolbarItem(String
the text to be displayed on the ToolbarItem
text
,
Node
the graphic to be displayed on the ToolbarItem
graphic
,
EventHandler<? super MouseEvent>
the function to be called when a mouse button has been clicked (pressed and released) on this Control
onClick
)

Creates a new ToolbarItem which appears like a Button, using the given text and graphic as button content and the onClick as onMouseClicked event.

public
ToolbarItem(String
the text to be displayed on the ToolbarItem
text
,
MenuItem...
the items to be displayed in the context-menu of the ToolbarItem
items
)

Creates a new ToolbarItem which appears like a MenuButton, using the given text as menu button text and the items as its MenuItems.

public
ToolbarItem(Node
the graphic to be displayed on the ToolbarItem
graphic
,
MenuItem...
the items to be displayed in the context-menu of the ToolbarItem
items
)

Creates a new ToolbarItem which appears like a MenuButton, using the given graphic as button menu button graphic and the items as its MenuItems.

public
ToolbarItem(String
the text to be displayed on the ToolbarItem
text
,
Node
the graphic to be displayed on the ToolbarItem
graphic
,
MenuItem...
the items to be displayed in the context-menu of the ToolbarItem
items
)

Creates a new ToolbarItem which appears like a MenuButton, using the given text and graphic as button menu button content and the items as its MenuItems.

Method Summary

Modifier and TypeMethod and Description
public final EventHandler<? super MouseEvent>
public final ObjectProperty<EventHandler<? super MouseEvent>>
public final void
private void
private void
Inherited from javafx.scene.control.MenuButton:
createDefaultSkinexecuteAccessibleActionfiregetItemsgetOnHiddengetOnHidinggetOnShowinggetOnShowngetPopupSidehideisShowingonHiddenPropertyonHidingPropertyonShowingPropertyonShownPropertypopupSidePropertysetOnHiddensetOnHidingsetOnShowingsetOnShownsetPopupSideshowshowingProperty

Field Detail

ICON_RESIZING_FACTORback to summary
private static final double ICON_RESIZING_FACTOR

Used to bind the fit size dimensions of an ImageView to this Controls pref height. The resizing factor ensures, that the ImageView doesn't exceed the defined icon size of 16px.

ICON_SIZEback to summary
private static final double ICON_SIZE

According to the material design standards, a desktop icon should have a size of 16x16px.

See Also
material.io
LOGGERback to summary
private static final Logger LOGGER
onClickback to summary
private final ObjectProperty<EventHandler<? super MouseEvent>> onClick
TOOLBAR_BUTTONback to summary
private static final String TOOLBAR_BUTTON

The style class which is used to style the ToolbarItem as a Button.

TOOLBAR_LABELback to summary
private static final String TOOLBAR_LABEL

The style class which is used to style the ToolbarItem as a Label.

TOOLBAR_MENU_BUTTONback to summary
private static final String TOOLBAR_MENU_BUTTON

The style class which is used to style the ToolbarItem as a MenuButton.

TOOLBAR_PADDINGback to summary
private static final double TOOLBAR_PADDING

The WorkbenchFX styles define a toolbar height of 40px with a padding of 3px on top and bottom.

TOTAL_ICON_SIZEback to summary
private static final double TOTAL_ICON_SIZE

The icon should be placed in a square of 40x40px as clearance.

Constructor Detail

ToolbarItemback to summary
public ToolbarItem()

Creates a new empty ToolbarItem. Use setText(String), setGraphic(Node), getItems() or setOnClick(EventHandler) to define the content.

ToolbarItemback to summary
public ToolbarItem(String text)

Creates a new ToolbarItem which appears like a Label, using the given text as label text.

Parameters
text:String

to be displayed on the ToolbarItem

ToolbarItemback to summary
public ToolbarItem(Node graphic)

Creates a new ToolbarItem which appears like a Label, using the given graphic as label graphic.

Parameters
graphic:Node

to be displayed on the ToolbarItem

ToolbarItemback to summary
public ToolbarItem(String text, Node graphic)

Creates a new ToolbarItem which appears like a Label, using the given text and graphic as label content.

Parameters
text:String

to be displayed on the ToolbarItem

graphic:Node

to be displayed on the ToolbarItem

ToolbarItemback to summary
public ToolbarItem(String text, EventHandler<? super MouseEvent> onClick)

Creates a new ToolbarItem which appears like a Button, using the given text as button text and the onClick as onMouseClicked event.

Parameters
text:String

to be displayed on the ToolbarItem

onClick:EventHandler<? super MouseEvent>

the function to be called when a mouse button has been clicked (pressed and released) on this Control

ToolbarItemback to summary
public ToolbarItem(Node graphic, EventHandler<? super MouseEvent> onClick)

Creates a new ToolbarItem which appears like a Button, using the given graphic as button graphic and the onClick as onMouseClicked event.

Parameters
graphic:Node

the graphic to be displayed on the ToolbarItem

onClick:EventHandler<? super MouseEvent>

the function to be called when a mouse button has been clicked (pressed and released) on this Control

ToolbarItemback to summary
public ToolbarItem(String text, Node graphic, EventHandler<? super MouseEvent> onClick)

Creates a new ToolbarItem which appears like a Button, using the given text and graphic as button content and the onClick as onMouseClicked event.

Parameters
text:String

the text to be displayed on the ToolbarItem

graphic:Node

the graphic to be displayed on the ToolbarItem

onClick:EventHandler<? super MouseEvent>

the function to be called when a mouse button has been clicked (pressed and released) on this Control

ToolbarItemback to summary
public ToolbarItem(String text, MenuItem... items)

Creates a new ToolbarItem which appears like a MenuButton, using the given text as menu button text and the items as its MenuItems.

Parameters
text:String

the text to be displayed on the ToolbarItem

items:MenuItem[]

the items to be displayed in the context-menu of the ToolbarItem

ToolbarItemback to summary
public ToolbarItem(Node graphic, MenuItem... items)

Creates a new ToolbarItem which appears like a MenuButton, using the given graphic as button menu button graphic and the items as its MenuItems.

Parameters
graphic:Node

the graphic to be displayed on the ToolbarItem

items:MenuItem[]

the items to be displayed in the context-menu of the ToolbarItem

ToolbarItemback to summary
public ToolbarItem(String text, Node graphic, MenuItem... items)

Creates a new ToolbarItem which appears like a MenuButton, using the given text and graphic as button menu button content and the items as its MenuItems.

Parameters
text:String

the text to be displayed on the ToolbarItem

graphic:Node

the graphic to be displayed on the ToolbarItem

items:MenuItem[]

the items to be displayed in the context-menu of the ToolbarItem

Method Detail

getOnClickback to summary
public final EventHandler<? super MouseEvent> getOnClick()
onClickPropertyback to summary
public final ObjectProperty<EventHandler<? super MouseEvent>> onClickProperty()
setOnClickback to summary
public final void setOnClick(EventHandler<? super MouseEvent> onClick)
setupListenersback to summary
private void setupListeners()
updateStyleClassesback to summary
private void updateStyleClasses()