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");
});
}
@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.BooleanProperty |
autoHideProgressBar
Decides if a determinate
ProgressBar should hide itself when the progressProperty() reaches
the threshold value i.e. |
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.beans.property.BooleanProperty |
progressBarVisible
The visible property of the
ProgressBar shown on the AppBar. |
javafx.beans.property.DoubleProperty |
progress
The progress of the
ProgressBar attached to the AppBar . |
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.
|
contextMenu, skinClassName, skin, tooltip
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, impl_showMnemonics, impl_treeVisible, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
Constructor and Description |
---|
AppBar()
Creates a new instance of AppBar.
|
Modifier and Type | Method and Description |
---|---|
javafx.beans.property.BooleanProperty |
autoHideProgressBarProperty()
Decides if a determinate
ProgressBar should hide itself when the progressProperty() reaches
the threshold value i.e. |
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 |
getProgress()
Gets the value of the property progress.
|
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.
|
boolean |
isAutoHideProgressBar()
Gets the value of the property autoHideProgressBar.
|
boolean |
isProgressBarVisible()
Gets the value of the property progressBarVisible.
|
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.
|
javafx.beans.property.BooleanProperty |
progressBarVisibleProperty()
The visible property of the
ProgressBar shown on the AppBar. |
javafx.beans.property.DoubleProperty |
progressProperty()
The progress of the
ProgressBar attached to the AppBar . |
void |
setAutoHideProgressBar(boolean autoHideProgressBar)
Sets the value of the property autoHideProgressBar.
|
void |
setNavIcon(javafx.scene.Node navIcon)
Sets a node as the nav icon.
|
void |
setProgress(double value)
Sets the value of the property progress.
|
void |
setProgressBarVisible(boolean progressBarVisible)
Sets the value of the property progressBarVisible.
|
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.beans.property.DoubleProperty progressProperty
ProgressBar
attached to the AppBar
.
The ProgressBar
can be either indeterminate or determinate depending on the value of this property.
A negative value for progress indicates that the progress is indeterminate. A positive value
between 0 and 1 indicates the percentage of progress where 0 is 0% and 1
is 100%. Any value greater than 1 is interpreted as 100%.ProgressIndicator.INDETERMINATE_PROGRESS
getProgress()
,
setProgress(double)
public final javafx.beans.property.BooleanProperty progressBarVisibleProperty
ProgressBar
shown on the AppBar.isProgressBarVisible()
,
setProgressBarVisible(boolean)
public final javafx.beans.property.BooleanProperty autoHideProgressBarProperty
ProgressBar
should hide itself when the progressProperty()
reaches
the threshold value i.e. 1.0. If set as true and the progressProperty()
is greater than equal to 1.0,
the progressBarVisibleProperty()
will be set to false.
This property has no effect on an indeterminate ProgressBar
.
isAutoHideProgressBar()
,
setAutoHideProgressBar(boolean)
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.beans.property.DoubleProperty progressProperty()
ProgressBar
attached to the AppBar
.
The ProgressBar
can be either indeterminate or determinate depending on the value of this property.
A negative value for progress indicates that the progress is indeterminate. A positive value
between 0 and 1 indicates the percentage of progress where 0 is 0% and 1
is 100%. Any value greater than 1 is interpreted as 100%.ProgressIndicator.INDETERMINATE_PROGRESS
getProgress()
,
setProgress(double)
public final double getProgress()
ProgressBar
attached to the AppBar
.
The ProgressBar
can be either indeterminate or determinate depending on the value of this property.
A negative value for progress indicates that the progress is indeterminate. A positive value
between 0 and 1 indicates the percentage of progress where 0 is 0% and 1
is 100%. Any value greater than 1 is interpreted as 100%.ProgressIndicator.INDETERMINATE_PROGRESS
public final void setProgress(double value)
ProgressBar
attached to the AppBar
.
The ProgressBar
can be either indeterminate or determinate depending on the value of this property.
A negative value for progress indicates that the progress is indeterminate. A positive value
between 0 and 1 indicates the percentage of progress where 0 is 0% and 1
is 100%. Any value greater than 1 is interpreted as 100%.ProgressIndicator.INDETERMINATE_PROGRESS
public final javafx.beans.property.BooleanProperty progressBarVisibleProperty()
ProgressBar
shown on the AppBar.isProgressBarVisible()
,
setProgressBarVisible(boolean)
public final boolean isProgressBarVisible()
ProgressBar
shown on the AppBar.public final void setProgressBarVisible(boolean progressBarVisible)
ProgressBar
shown on the AppBar.public final javafx.beans.property.BooleanProperty autoHideProgressBarProperty()
ProgressBar
should hide itself when the progressProperty()
reaches
the threshold value i.e. 1.0. If set as true and the progressProperty()
is greater than equal to 1.0,
the progressBarVisibleProperty()
will be set to false.
This property has no effect on an indeterminate ProgressBar
.
isAutoHideProgressBar()
,
setAutoHideProgressBar(boolean)
public final boolean isAutoHideProgressBar()
ProgressBar
should hide itself when the progressProperty()
reaches
the threshold value i.e. 1.0. If set as true and the progressProperty()
is greater than equal to 1.0,
the progressBarVisibleProperty()
will be set to false.
This property has no effect on an indeterminate ProgressBar
.
public final void setAutoHideProgressBar(boolean autoHideProgressBar)
ProgressBar
should hide itself when the progressProperty()
reaches
the threshold value i.e. 1.0. If set as true and the progressProperty()
is greater than equal to 1.0,
the progressBarVisibleProperty()
will be set to false.
This property has no effect on an indeterminate ProgressBar
.
public final javafx.css.StyleableDoubleProperty spacingProperty()
getActionItems()
.getSpacing()
,
setSpacing(double)
public final void setSpacing(double value)
getActionItems()
.public final double getSpacing()
getActionItems()
.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