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 dragType
attached property.
HeaderBar is a layout container that allows applications to place scene graph nodes in three areas:
left, center, and right.
All areas can be null. The default minHeight of the HeaderBar is
set to match systemMinHeight (unless explicitly set by a stylesheet or
application code), which usually corresponds to the height of the system-provided 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 areas reserved for the system-provided header buttons, correctly align with the location
of the HeaderBar and are taken into account when the contents of the HeaderBar are laid out.
leftSystemPadding and
rightSystemPadding properties can be used to remove the padding
that is not needed.
systemButtonHeight attached property for 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.
systemColorScheme attached property.
systemButtonHeight attached property for
the Stage associated with the header bar 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 specifying its semantic
type with the buttonType attached property.
Stage is in full-screen mode, or
HeaderBar has consumed the
ContextMenuEvent#CONTEXT_MENU_REQUESTED event.
left and right 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 being 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 (such as 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 ObjectProperty | center
The center area of the |
| private ObjectProperty | |
| private BooleanProperty | leftSystemPadding
Specifies whether additional padding should be added to the left side of the |
| private static final String | |
| private ObjectProperty | |
| private BooleanProperty | rightSystemPadding
Specifies whether additional padding should be added to the right side of the |
| private Subscription | |
| public static final double | USE_DEFAULT_SIZE
Sentinel value that can be used for the |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static ObjectProperty | Returns: thebuttonType propertythe child node child)Specifies the |
| 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 ObjectProperty | Returns: thedragType propertythe child node child)Specifies the |
| 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)Gets the value of the |
| public final Node | |
| public static HeaderDragType | Returns: theHeaderDragType, or null if not setthe child node child)Gets the value of the |
| public final Node | |
| public static Dimension2D | Returns: the size of the left system-reserved insetthe stage)StageGets the value of the |
| public static Insets | |
| private Insets | |
| public final Node | |
| public static Dimension2D | Returns: the size of the right system-reserved insetthe stage)StageGets the value of the |
| public static double | Returns: the preferred height of the system-provided header buttonsthe stage)StageGets the value of the |
| public static ColorScheme | Returns: the color schemethe stage)StageGets the value of the |
| public static double | Returns: the system-recommended minimum height for theHeaderBarthe stage)StageGets the value of the |
| public final boolean | |
| public final boolean | |
| protected void | layoutChildren()
Overrides javafx. Invoked during the layout pass to layout the children in this
|
| public final ObjectProperty | |
| public static ReadOnlyObjectProperty | Returns: theleftSystemInset attached propertythe stage)StageDescribes the size of the left system-reserved inset for the specified |
| public final BooleanProperty | |
| private void | |
| private double | resizeChild(Node child, double adjustedWidth, boolean fillWidth, double insideHeight, Insets margin)
|
| public final ObjectProperty | |
| public static ReadOnlyObjectProperty | Returns: therightSystemInset attached propertythe stage)StageDescribes the size of the right system-reserved inset for the specified |
| public final BooleanProperty | |
| 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 nullSets the value of the |
| public final void | |
| public static void | setDragType(Node
the child node child, HeaderDragType the value)HeaderDragType, or null to remove the flagSets the value of the |
| public final void | |
| public final void | |
| public static void | |
| public final void | |
| public final void | |
| public static void | setSystemButtonHeight(Stage
the stage, double Stagethe preferred height, or 0 to hide the system-provided header buttons height)Sets the value of the |
| public static void | setSystemColorScheme(Stage
the stage, ColorScheme Stagethe color scheme, or value)null to indicate no preferenceSets the value of the |
| public static DoubleProperty | Returns: thesystemButtonHeight attached propertythe stage)StageSpecifies the preferred height of the system-provided header buttons for the specified |
| public static ObjectProperty | Returns: thesystemColorScheme attached propertythe stage)StageSpecifies the color scheme of the system-provided header buttons for the specified |
| public static ReadOnlyDoubleProperty | Returns: thesystemMinHeight attached propertythe stage)StageSpecifies the system-recommended minimum height for the |
| ALIGNMENT | back to summary |
|---|---|
| private static final String ALIGNMENT | |
| center | back to summary |
|---|---|
| private ObjectProperty<Node> center The center area of the
| |
| left | back to summary |
|---|---|
| private ObjectProperty<Node> left Hides javafx. The left area of the
| |
| leftSystemPadding | back to summary |
|---|---|
| private BooleanProperty leftSystemPadding Specifies whether additional padding should be added to the left side of the
Applications that use a single
| |
| MARGIN | back to summary |
|---|---|
| private static final String MARGIN | |
| right | back to summary |
|---|---|
| private ObjectProperty<Node> right Hides javafx. The right area of the
| |
| rightSystemPadding | back to summary |
|---|---|
| private BooleanProperty rightSystemPadding Specifies whether additional padding should be added to the right side of the
Applications that use a single
| |
| subscriptions | back to summary |
|---|---|
| private Subscription subscriptions | |
| USE_DEFAULT_SIZE | back to summary |
|---|---|
| public static final double USE_DEFAULT_SIZE Sentinel value that can be used for the | |
| HeaderBar | back to summary |
|---|---|
| public HeaderBar() Creates a new | |
| HeaderBar | back to summary |
|---|---|
| public HeaderBar(Node left, Node center, Node right) Creates a new | |
| buttonTypeProperty | back to summary |
|---|---|
| public static ObjectProperty Specifies the
This property can be set on any
| |
| 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.
| |
| dragTypeProperty | back to summary |
|---|---|
| public static ObjectProperty Specifies the
| |
| 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) Gets the value of the
| |
| getCenter | back to summary |
|---|---|
| public final Node getCenter() | |
| getDragType | back to summary |
|---|---|
| public static HeaderDragType getDragType(Node child) Gets the value of the
| |
| getLeft | back to summary |
|---|---|
| public final Node getLeft() | |
| getLeftSystemInset | back to summary |
|---|---|
| public static Dimension2D getLeftSystemInset(Stage stage) Gets the value of the
| |
| getMargin | back to summary |
|---|---|
| public static Insets getMargin(Node child) Returns the child's margin. | |
| getNodeMargin | back to summary |
|---|---|
| private Insets getNodeMargin(Node child) | |
| getRight | back to summary |
|---|---|
| public final Node getRight() | |
| getRightSystemInset | back to summary |
|---|---|
| public static Dimension2D getRightSystemInset(Stage stage) Gets the value of the
| |
| getSystemButtonHeight | back to summary |
|---|---|
| public static double getSystemButtonHeight(Stage stage) Gets the value of the
| |
| getSystemColorScheme | back to summary |
|---|---|
| public static ColorScheme getSystemColorScheme(Stage stage) Gets the value of the
| |
| getSystemMinHeight | back to summary |
|---|---|
| public static double getSystemMinHeight(Stage stage) Gets the value of the
| |
| isLeftSystemPadding | back to summary |
|---|---|
| public final boolean isLeftSystemPadding() | |
| isRightSystemPadding | back to summary |
|---|---|
| public final boolean isRightSystemPadding() | |
| 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.
| |
| leftProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| leftSystemInsetProperty | back to summary |
|---|---|
| public static ReadOnlyObjectProperty Describes the size of the left system-reserved inset for the specified
| |
| leftSystemPaddingProperty | back to summary |
|---|---|
| public final BooleanProperty leftSystemPaddingProperty() | |
| 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) | |
| rightProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| rightSystemInsetProperty | back to summary |
|---|---|
| public static ReadOnlyObjectProperty Describes the size of the right system-reserved inset for the specified
| |
| rightSystemPaddingProperty | back to summary |
|---|---|
| public final BooleanProperty rightSystemPaddingProperty() | |
| 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) Sets the value of the
| |
| setCenter | back to summary |
|---|---|
| public final void setCenter(Node value) | |
| setDragType | back to summary |
|---|---|
| public static void setDragType(Node child, HeaderDragType value) Sets the value of the
| |
| setLeft | back to summary |
|---|---|
| public final void setLeft(Node value) | |
| setLeftSystemPadding | back to summary |
|---|---|
| public final void setLeftSystemPadding(boolean value) | |
| setMargin | back to summary |
|---|---|
| public static void setMargin(Node child, Insets value) Sets the margin for the child when contained in a | |
| setRight | back to summary |
|---|---|
| public final void setRight(Node value) | |
| setRightSystemPadding | back to summary |
|---|---|
| public final void setRightSystemPadding(boolean value) | |
| setSystemButtonHeight | back to summary |
|---|---|
| public static void setSystemButtonHeight(Stage stage, double height) Sets the value of the
| |
| setSystemColorScheme | back to summary |
|---|---|
| public static void setSystemColorScheme(Stage stage, ColorScheme value) Sets the value of the
| |
| systemButtonHeightProperty | back to summary |
|---|---|
| public static DoubleProperty systemButtonHeightProperty(Stage stage) Specifies the preferred height of the system-provided header buttons for the specified
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
| |
| systemColorSchemeProperty | back to summary |
|---|---|
| public static ObjectProperty Specifies the color scheme of the system-provided header buttons for the specified
This is a null-coalescing property: if set to The specified color scheme is only a hint for the platform window toolkit and may be ignored.
| |
| systemMinHeightProperty | back to summary |
|---|---|
| public static ReadOnlyDoubleProperty systemMinHeightProperty(Stage stage) Specifies the system-recommended minimum height for the
By default,
| |
| 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
| |