public class AppBar
extends javafx.scene.control.Control
The AppBar is a special kind of toolbar that is used for branding, navigation, search, and actions. It is placed at the top of the view and is generally made up of:
NavigationDrawer
or to move back in the view stackLabel
used to describe the current view
A single instance of the AppBar is initialized by the application during its construction
and therefore, need not be instantiated by the user.
To change the elements of this control its instance can be fetched from
MobileApplication.getInstance().getAppBar()
.
The recommended node for Nav Icon and Action Icons is a button
. Appropriate styling is automatically
applied to buttons
. To create a button
without any text and only an Icon,
use MaterialDesignIcon.button()
. However, a user is not restricted to use buttons
and can use any Node
, with custom style(s).
For developers, it is recommended to use the same color for all icons.
View.updateAppBar(AppBar)
method or in a listener for View.showingProperty()
and remove it
in the View
HIDDEN event, the following code illustrates this:
public SomeView(String name) {
...
setOnHidden(event -> {
appBar.getStyleClass().remove("foo");
});
}
{@literal @}Override
protected void updateAppBar(AppBar appBar) {
appBar.getStyleClass().add("foo");
...
}
The following example fills the contents of an AppBar:
AppBar appBar = MobileApplication.getInstance().getAppBar(); appBar.setNavIcon(MaterialDesignIcon.MENU.button()); appBar.setTitleText("The AppBar"); appBar.getActionItems().addAll(MaterialDesignIcon.SEARCH.button(), MaterialDesignIcon.FAVORITE.button()); appBar.getMenuItems().add(new MenuItem("Settings"));Every time a new
View
is loaded, the AppBar controls are removed, and its visibility
is reset to true, so developers will need to provide at this point the new controls
for the AppBar in this new View, either by overriding View.updateAppBar(com.gluonhq.charm.glisten.control.AppBar)
,
by adding an event handler to the SHOWING
event or by listening to View.showingProperty()
.
The method clear()
can be called to remove all the elements from
AppBar and reset visibility of the control to true.
MobileApplication
,
View
Type | Property and Description |
---|---|
javafx.beans.property.ObjectProperty<javafx.scene.Node> |
navIcon
The left-most node in the app bar, and is often used to show a side popup menu
or to move back in the view stack.
|
javafx.css.StyleableDoubleProperty |
spacing
The amount of horizontal space between each child in the AppBar.
|
javafx.beans.property.ObjectProperty<javafx.scene.Node> |
title
The title in the app bar reflects the current page.
|
javafx.beans.property.StringProperty |
titleText
The title in the app bar reflects the current page.
|
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthProperty
impl_traversalEngineProperty, needsLayoutProperty
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, impl_showMnemonicsProperty, impl_treeVisibleProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
Constructor and Description |
---|
AppBar()
Creates a new instance of AppBar.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the
AppBar leaving it with no nav icon, title, action icons or menu items. |
protected javafx.scene.control.Skin<?> |
createDefaultSkin() |
javafx.collections.ObservableList<javafx.scene.Node> |
getActionItems()
Gets the action items.
|
static java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> |
getClassCssMetaData() |
java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> |
getControlCssMetaData() |
javafx.collections.ObservableList<javafx.scene.control.MenuItem> |
getMenuItems()
Gets the menu items listed in the overflow menu.
|
javafx.scene.Node |
getNavIcon()
Returns a node which is used as the nav icon.
|
double |
getSpacing()
Gets the value of the property spacing.
|
javafx.scene.Node |
getTitle()
Returns the title of the AppBar.
|
java.lang.String |
getTitleText()
Returns a String with the title of the AppBar.
|
javafx.beans.property.ObjectProperty<javafx.scene.Node> |
navIconProperty()
The left-most node in the app bar, and is often used to show a side popup menu
or to move back in the view stack.
|
void |
setNavIcon(javafx.scene.Node navIcon)
Sets a node as the nav icon.
|
void |
setSpacing(double value)
Sets the value of the property spacing.
|
void |
setTitle(javafx.scene.Node title)
Changes the title of the AppBar.
|
void |
setTitleText(java.lang.String titleText)
Sets the title of the AppBar.
|
javafx.css.StyleableDoubleProperty |
spacingProperty()
The amount of horizontal space between each child in the AppBar.
|
javafx.beans.property.ObjectProperty<javafx.scene.Node> |
titleProperty()
The title in the app bar reflects the current page.
|
javafx.beans.property.StringProperty |
titleTextProperty()
The title in the app bar reflects the current page.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getSkin, getTooltip, impl_cssGetFocusTraversableInitialValue, impl_processCSS, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> titleProperty
navIcon
in the AppBar
.titleTextProperty()
public final javafx.beans.property.StringProperty titleTextProperty
titleProperty()
being a Label
with this property value as the text.
This property might not reflect the actual title since this is not always
synchronized with titleProperty()
.getTitleText()
,
setTitleText(String)
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> navIconProperty
getNavIcon()
,
setNavIcon(Node)
public final javafx.css.StyleableDoubleProperty spacingProperty
getActionItems()
.getSpacing()
,
setSpacing(double)
public final javafx.scene.Node getTitle()
Node
.getTitleText()
public final javafx.beans.property.ObjectProperty<javafx.scene.Node> titleProperty()
navIcon
in the AppBar
.titleTextProperty()
public final void setTitle(javafx.scene.Node title)
title
- The new title Node
.setTitleText(String)
public final java.lang.String getTitleText()
String
with the title. This might not be
the current title in the AppBar
since setTitle(Node)
might be called and titleProperty()
and titleTextProperty()
are not always synchronized.getTitle()
public final javafx.beans.property.StringProperty titleTextProperty()
titleProperty()
being a Label
with this property value as the text.
This property might not reflect the actual title since this is not always
synchronized with titleProperty()
.getTitleText()
,
setTitleText(String)
public final void setTitleText(java.lang.String titleText)
titleText
- The current title of AppBar
.setTitle(Node)
public final javafx.collections.ObservableList<javafx.scene.Node> getActionItems()
AppBar
suggest that the most common actionItems to place within it
are Buttons
with just a graphic,
but you are not restricted to just these, and can insert any Node
.
The actionItems are placed between the title and the overflow menu, aligned right to left.
The actionItems added must not be null.ObservableList
of Node
containing the action items.public final javafx.collections.ObservableList<javafx.scene.control.MenuItem> getMenuItems()
MenuItem
to the ObservableList
returned by this method.ObservableList
of MenuItem
which is shown when an ActionEvent
is triggered on the menu icon of the AppBar
.public final javafx.scene.Node getNavIcon()
Node
containing the nav icon instance.public final javafx.beans.property.ObjectProperty<javafx.scene.Node> navIconProperty()
getNavIcon()
,
setNavIcon(Node)
public final void setNavIcon(javafx.scene.Node navIcon)
Sets a node as the nav icon. The nav icon is the left-most node of the app bar and can be:
Normally, a user is advised to add a Button
as the node. A Button
will receive
the appropriate styling automatically. Nevertheless, a user is not restricted to a Button
and may add any node with custom style.
navIcon
- The nav icon of the AppBar
public final javafx.css.StyleableDoubleProperty spacingProperty()
getActionItems()
.getSpacing()
,
setSpacing(double)
public final void setSpacing(double value)
public final double getSpacing()
public void clear()
AppBar
leaving it with no nav icon, title, action icons or menu items.
The visibility of AppBar is also reset to true.protected javafx.scene.control.Skin<?> createDefaultSkin()
createDefaultSkin
in class javafx.scene.control.Control
public static java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> getClassCssMetaData()
public java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,?>> getControlCssMetaData()
getControlCssMetaData
in class javafx.scene.control.Control