Deprecated
since 25.
This is a preview feature which may be changed or removed in a future release.
StageStyle#EXTENDED style. This class enables the click-and-drag to move and
double-click to maximize behaviors that are usually afforded by system-provided header bars.
The entire HeaderBar background is draggable by default, but its content is not. Applications
can specify draggable content nodes of the HeaderBar with the setDragType(Node, HeaderDragType)
method.
HeaderBar is a layout container that allows applications to place scene graph nodes in three areas:
leading, center, and trailing.
All areas can be null. The default minHeight of the HeaderBar is
set to match the height of the platform-specific default header buttons.
HeaderBar to the scene graph, placed at the top of the
scene and extending its entire width. This ensures that the reported values for
leftSystemInset and rightSystemInset,
which describe the area reserved for the system-provided window buttons, correctly align with the location
of the HeaderBar and are taken into account when the contents of the HeaderBar are laid out.
leadingSystemPadding and
trailingSystemPadding properties can be used to remove the padding
that is not needed.
setPrefButtonHeight(Stage, double) property on the Stage associated with the header bar.
This can be used to achieve a more cohesive visual appearance by having the system-provided header buttons
match the height of the client-area header bar.
setPrefButtonHeight(Stage, double) to zero and place custom header buttons in
the JavaFX scene graph instead. Any JavaFX control can be used as a custom header button by setting its
semantic type with the setButtonType(Node, HeaderButtonType) method.
Stage is in full-screen mode, or
HeaderBar has consumed the
ContextMenuEvent#CONTEXT_MENU_REQUESTED event.
leading and trailing children will be resized to their preferred widths and extend the
height of the HeaderBar. The center child will be resized to fill the available space.
HeaderBar honors the minimum, preferred, and maximum sizes of its children. If a child's resizable
range prevents it from be resized to fit within its position, it will be vertically centered relative to the
available space; this alignment can be customized with a layout constraint.
An application may set constraints on individual children to customize their layout.
For each constraint, HeaderBar provides static getter and setter methods.
| Constraint | Type | Description |
|---|---|---|
| alignment | Pos |
The alignment of the child within its area of the HeaderBar. |
| margin | Insets | Margin space around the outside of the child. |
center area (i.e. its alignment
constraint is either null, Pos#CENTER, Pos#TOP_CENTER, or Pos#BOTTOM_CENTER),
it will be centered with respect to the entire header bar, and not with respect to the center area only.
This means that, for a header bar that extends the entire width of the Stage, the child will appear to
be horizontally centered within the Stage.
If a child should instead be centered with respect to the center area only, a possible solution is to
place another layout container like BorderPane in the center area, and then center the child
within the other layout container.
HeaderBar is placed in a root container like BorderPane to align it
with the top of the scene:
public class MyApp extends Application {
@Override
public void start(Stage stage) {
var button = new Button("My button");
HeaderBar.setAlignment(button, Pos.CENTER_LEFT);
HeaderBar.setMargin(button, new Insets(5));
var headerBar = new HeaderBar();
headerBar.setCenter(button);
var root = new BorderPane();
root.setTop(headerBar);
stage.setScene(new Scene(root));
stage.initStyle(StageStyle.EXTENDED);
stage.show();
}
}
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final String | |
| private final ObjectProperty | center
The center area of the |
| private boolean | |
| private HeaderButtonMetrics | |
| private static final String | |
| private static final Dimension2D | |
| private final ObjectProperty | leading
The leading area of the |
| private final BooleanProperty | leadingSystemPadding
Specifies whether additional padding should be added to the leading side of the |
| private final ReadOnlyObjectWrapper | leftSystemInset
Describes the size of the left system-reserved inset, which is an area reserved for the iconify, maximize, and close window buttons. |
| private static final String | |
| private final ReadOnlyDoubleWrapper | minSystemHeight
The system-provided minimum recommended height for the |
| private final ReadOnlyObjectWrapper | rightSystemInset
Describes the size of the right system-reserved inset, which is an area reserved for the iconify, maximize, and close window buttons. |
| private Subscription | |
| private final ObjectProperty | trailing
The trailing area of the |
| private final BooleanProperty | trailingSystemPadding
Specifies whether additional padding should be added to the trailing side of the |
| public static final double | USE_DEFAULT_SIZE
Sentinel value that can be used for |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private Insets | |
| public final ObjectProperty | |
| private boolean | |
| protected double | computeMinHeight(double width)
Overrides javafx. Computes the minimum height of this region. |
| protected double | computeMinWidth(double height)
Overrides javafx. Computes the minimum width of this region. |
| protected double | computePrefHeight(double width)
Overrides javafx. Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. |
| public static Pos | Returns: the alignment position for the child, ornull if no alignment was setthe child node child)Returns the child's alignment in the |
| private double | |
| private double | |
| public static HeaderButtonType | Returns: theHeaderButtonType, or nullthe child node child)
References Deprecated
HeaderButtonType is deprecated or references (maybe indirectly) at least one deprecated element.
Returns the |
| public final Node | |
| public static HeaderDragType | Returns: theHeaderDragType, or null if not setthe child node child)
References Deprecated
HeaderDragType is deprecated or references (maybe indirectly) at least one deprecated element.
Returns the |
| public final Node | |
| public final Dimension2D | |
| public static Insets | |
| public final double | |
| private Insets | |
| public static double | Returns: the preferred height of the system-provided header buttonsthe stage)StageReturns the preferred height of the system-provided header buttons of the specified stage. |
| public final Dimension2D | |
| public final Node | |
| public final boolean | |
| private boolean | |
| private boolean | |
| public final boolean | |
| protected void | layoutChildren()
Overrides javafx. Invoked during the layout pass to layout the children in this
|
| public final ObjectProperty | |
| public final BooleanProperty | |
| public final ReadOnlyObjectProperty | |
| public final ReadOnlyDoubleProperty | |
| private void | |
| private void | |
| private void | |
| private double | resizeChild(Node child, double adjustedWidth, boolean fillWidth, double insideHeight, Insets margin)
|
| public final ReadOnlyObjectProperty | |
| public static void | setAlignment(Node
the child node child, Pos the alignment position value)Sets the alignment for the child when contained in a |
| public static void | setButtonType(Node
the child node child, HeaderButtonType the value)HeaderButtonType, or null
References Deprecated
HeaderButtonType is deprecated or references (maybe indirectly) at least one deprecated element.
Specifies the |
| public final void | |
| public static void | setDragType(Node
the child node child, HeaderDragType the value)HeaderDragType, or null to remove the flag
References Deprecated
HeaderDragType is deprecated or references (maybe indirectly) at least one deprecated element.
Specifies the |
| public final void | |
| public final void | |
| public static void | |
| public static void | setPrefButtonHeight(Stage
the stage, double Stagethe preferred height, or 0 to hide the system-provided header buttons height)Specifies the preferred height of the system-provided header buttons of the specified stage. |
| public final void | |
| public final void | |
| public final ObjectProperty | |
| public final BooleanProperty | |
| private void | |
| public boolean | usesMirroring()
Overrides javafx. Determines whether a node should be mirrored when node orientation is right-to-left. |
| ALIGNMENT | back to summary |
|---|---|
| private static final String ALIGNMENT | |
| BUTTON_TYPE | back to summary |
|---|---|
| private static final String BUTTON_TYPE | |
| center | back to summary |
|---|---|
| private final ObjectProperty<Node> center The center area of the
| |
| currentFullScreen | back to summary |
|---|---|
| private boolean currentFullScreen | |
| currentMetrics | back to summary |
|---|---|
| private HeaderButtonMetrics currentMetrics | |
| DRAG_TYPE | back to summary |
|---|---|
| private static final String DRAG_TYPE | |
| EMPTY | back to summary |
|---|---|
| private static final Dimension2D EMPTY | |
| leading | back to summary |
|---|---|
| private final ObjectProperty<Node> leading The leading area of the The leading area corresponds to the left area in a left-to-right layout, and to the right area in a right-to-left layout.
| |
| leadingSystemPadding | back to summary |
|---|---|
| private final BooleanProperty leadingSystemPadding Specifies whether additional padding should be added to the leading side of the
Applications that use a single
| |
| leftSystemInset | back to summary |
|---|---|
| private final ReadOnlyObjectWrapper<Dimension2D> leftSystemInset Describes the size of the left system-reserved inset, which is an area reserved for the iconify, maximize,
and close window buttons. If there are no window buttons on the left side of the window, the returned area
is an empty Note that the left system inset refers to the left side of the window, independent of layout orientation. | |
| MARGIN | back to summary |
|---|---|
| private static final String MARGIN | |
| minSystemHeight | back to summary |
|---|---|
| private final ReadOnlyDoubleWrapper minSystemHeight The system-provided minimum recommended height for the
By default, | |
| rightSystemInset | back to summary |
|---|---|
| private final ReadOnlyObjectWrapper<Dimension2D> rightSystemInset Describes the size of the right system-reserved inset, which is an area reserved for the iconify, maximize,
and close window buttons. If there are no window buttons on the right side of the window, the returned area
is an empty Note that the right system inset refers to the right side of the window, independent of layout orientation. | |
| subscription | back to summary |
|---|---|
| private Subscription subscription | |
| trailing | back to summary |
|---|---|
| private final ObjectProperty<Node> trailing The trailing area of the The trailing area corresponds to the right area in a left-to-right layout, and to the left area in a right-to-left layout.
| |
| trailingSystemPadding | back to summary |
|---|---|
| private final BooleanProperty trailingSystemPadding Specifies whether additional padding should be added to the trailing side of the
Applications that use a single
| |
| USE_DEFAULT_SIZE | back to summary |
|---|---|
| public static final double USE_DEFAULT_SIZE Sentinel value that can be used for | |
| HeaderBar | back to summary |
|---|---|
| public HeaderBar() Creates a new | |
| HeaderBar | back to summary |
|---|---|
| public HeaderBar(Node leading, Node center, Node trailing) Creates a new | |
| adjustMarginForRTL | back to summary |
|---|---|
| private Insets adjustMarginForRTL(Insets margin, boolean rtl) | |
| centerProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| childHasContentBias | back to summary |
|---|---|
| private boolean childHasContentBias(Node child, Orientation orientation) | |
| computeMinHeight | back to summary |
|---|---|
| protected double computeMinHeight(double width) Overrides javafx. Doc from javafx. Computes the minimum height of this region. Returns the sum of the top and bottom insets by default. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computeMinWidth | back to summary |
|---|---|
| protected double computeMinWidth(double height) Overrides javafx. Doc from javafx. Computes the minimum width of this region. Returns the sum of the left and right insets by default. region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| computePrefHeight | back to summary |
|---|---|
| protected double computePrefHeight(double width) Overrides javafx. Doc from javafx. Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| getAlignment | back to summary |
|---|---|
| public static Pos getAlignment(Node child) Returns the child's alignment in the | |
| getAreaHeight | back to summary |
|---|---|
| private double getAreaHeight(Node child, double width, boolean minimum) | |
| getAreaWidth | back to summary |
|---|---|
| private double getAreaWidth(Node child, double height, boolean minimum) | |
| getButtonType | back to summary |
|---|---|
| public static HeaderButtonType getButtonType(Node child)
References Deprecated
See corresponding docs for further information. Returns the
| |
| getCenter | back to summary |
|---|---|
| public final Node getCenter() | |
| getDragType | back to summary |
|---|---|
| public static HeaderDragType getDragType(Node child)
References Deprecated
See corresponding docs for further information. Returns the
| |
| getLeading | back to summary |
|---|---|
| public final Node getLeading() | |
| getLeftSystemInset | back to summary |
|---|---|
| public final Dimension2D getLeftSystemInset() | |
| getMargin | back to summary |
|---|---|
| public static Insets getMargin(Node child) Returns the child's margin. | |
| getMinSystemHeight | back to summary |
|---|---|
| public final double getMinSystemHeight() | |
| getNodeMargin | back to summary |
|---|---|
| private Insets getNodeMargin(Node child) | |
| getPrefButtonHeight | back to summary |
|---|---|
| public static double getPrefButtonHeight(Stage stage) Returns the preferred height of the system-provided header buttons of the specified stage.
| |
| getRightSystemInset | back to summary |
|---|---|
| public final Dimension2D getRightSystemInset() | |
| getTrailing | back to summary |
|---|---|
| public final Node getTrailing() | |
| isLeadingSystemPadding | back to summary |
|---|---|
| public final boolean isLeadingSystemPadding() | |
| isLeftSystemPadding | back to summary |
|---|---|
| private boolean isLeftSystemPadding(NodeOrientation nodeOrientation) | |
| isRightSystemPadding | back to summary |
|---|---|
| private boolean isRightSystemPadding(NodeOrientation nodeOrientation) | |
| isTrailingSystemPadding | back to summary |
|---|---|
| public final boolean isTrailingSystemPadding() | |
| layoutChildren | back to summary |
|---|---|
| protected void layoutChildren() Overrides javafx. Doc from javafx. Invoked during the layout pass to layout the children in this
Subclasses should override this function to layout content as needed.
| |
| leadingProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| leadingSystemPaddingProperty | back to summary |
|---|---|
| public final BooleanProperty leadingSystemPaddingProperty() | |
| leftSystemInsetProperty | back to summary |
|---|---|
| public final ReadOnlyObjectProperty | |
| minSystemHeightProperty | back to summary |
|---|---|
| public final ReadOnlyDoubleProperty minSystemHeightProperty() | |
| onFullScreenChanged | back to summary |
|---|---|
| private void onFullScreenChanged(boolean fullScreen) | |
| onMetricsChanged | back to summary |
|---|---|
| private void onMetricsChanged(HeaderButtonMetrics metrics) | |
| onStageChanged | back to summary |
|---|---|
| private void onStageChanged(Stage stage) | |
| resizeChild | back to summary |
|---|---|
| private double resizeChild(Node child, double adjustedWidth, boolean fillWidth, double insideHeight, Insets margin) | |
| rightSystemInsetProperty | back to summary |
|---|---|
| public final ReadOnlyObjectProperty | |
| setAlignment | back to summary |
|---|---|
| public static void setAlignment(Node child, Pos value) Sets the alignment for the child when contained in a | |
| setButtonType | back to summary |
|---|---|
| public static void setButtonType(Node child, HeaderButtonType value)
References Deprecated
See corresponding docs for further information. Specifies the
This property can be set on any
| |
| setCenter | back to summary |
|---|---|
| public final void setCenter(Node value) | |
| setDragType | back to summary |
|---|---|
| public static void setDragType(Node child, HeaderDragType value)
References Deprecated
See corresponding docs for further information. Specifies the
Setting the value to
| |
| setLeading | back to summary |
|---|---|
| public final void setLeading(Node value) | |
| setLeadingSystemPadding | back to summary |
|---|---|
| public final void setLeadingSystemPadding(boolean value) | |
| setMargin | back to summary |
|---|---|
| public static void setMargin(Node child, Insets value) Sets the margin for the child when contained in a | |
| setPrefButtonHeight | back to summary |
|---|---|
| public static void setPrefButtonHeight(Stage stage, double height) Specifies the preferred height of the system-provided header buttons of the specified stage.
Any value except zero and
Setting the preferred height to zero hides the system-provided header buttons, allowing applications to
use custom header buttons instead (see
The default value
| |
| setTrailing | back to summary |
|---|---|
| public final void setTrailing(Node value) | |
| setTrailingSystemPadding | back to summary |
|---|---|
| public final void setTrailingSystemPadding(boolean value) | |
| trailingProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| trailingSystemPaddingProperty | back to summary |
|---|---|
| public final BooleanProperty trailingSystemPaddingProperty() | |
| updateInsets | back to summary |
|---|---|
| private void updateInsets() | |
| usesMirroring | back to summary |
|---|---|
| public boolean usesMirroring() Overrides javafx. Doc from javafx. Determines whether a node should be mirrored when node orientation is right-to-left.
When a node is mirrored, the origin is automatically moved to the
top right corner causing the node to layout children and draw from
right to left using a mirroring transformation. Some nodes may wish
to draw from right to left without using a transformation. These
nodes will answer
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Object | getBean()
Implements javafx. Returns the |
| public String | getName()
Implements javafx. Returns the name of this property. |
| protected void | invalidated()
Overrides javafx. The method |
| NodeProperty | back to summary |
|---|---|
| pack-priv NodeProperty(String name) | |
| getBean | back to summary |
|---|---|
| public Object getBean() Implements javafx. Doc from javafx. Returns the
| |
| getName | back to summary |
|---|---|
| public String getName() Implements javafx. Doc from javafx. Returns the name of this property. If the property does not have a name,
this method returns an empty
| |
| invalidated | back to summary |
|---|---|
| protected void invalidated() Overrides javafx. Doc from javafx. The method
| |