public class MenuBarSkin extends SkinBase<MenuBar>
Default skin implementation for the
MenuBar
control. In essence it is
a simple toolbar. For the time being there is no overflow behavior and we just
hide nodes which fall outside the bounds.- Since:
- 9
- See Also:
MenuBar
-
Property Summary
Properties Type Property Description ObjectProperty<Pos>
containerAlignment
Specifies the alignment of the menu buttons inside the MenuBar (by default it is Pos.TOP_LEFT).DoubleProperty
spacing
Specifies the spacing between menu buttons on the MenuBar. -
Constructor Summary
Constructors Constructor Description MenuBarSkin(MenuBar control)
Creates a new MenuBarSkin instance, installing the necessary child nodes into the Controlchildren
list, as well as the necessary input mappings for handling key, mouse, etc events. -
Method Summary
Modifier and Type Method Description protected double
computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
Computes the maximum allowable height of the Skin, based on the provided width.protected double
computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
Computes the minimum allowable height of the Skin, based on the provided width.protected double
computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
Computes the minimum allowable width of the Skin, based on the provided height.protected double
computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
Calculates the preferred height of thisSkinBase
.protected double
computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
Calculates the preferred width of thisSkinBase
.ObjectProperty<Pos>
containerAlignmentProperty()
Specifies the alignment of the menu buttons inside the MenuBar (by default it is Pos.TOP_LEFT).void
dispose()
Called by a Skinnable when the Skin is replaced on the Skinnable.static List<CssMetaData<? extends Styleable,?>>
getClassCssMetaData()
Returns the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.Pos
getContainerAlignment()
Gets the value of the property containerAlignment.List<CssMetaData<? extends Styleable,?>>
getCssMetaData()
This method should delegate toNode.getClassCssMetaData()
so that a Node's CssMetaData can be accessed without the need for reflection.double
getSpacing()
Gets the value of the property spacing.protected void
layoutChildren(double x, double y, double w, double h)
Called during the layout pass of the scenegraph.protected Object
queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)
This method is called by the assistive technology to request the value for an attribute.void
setContainerAlignment(Pos value)
Sets the value of the property containerAlignment.static void
setDefaultSystemMenuBar(MenuBar menuBar)
Set the default system menu bar.void
setSpacing(double value)
Sets the value of the property spacing.protected double
snappedBottomInset()
Utility method to get the bottom inset which includes padding and border inset.protected double
snappedLeftInset()
Utility method to get the left inset which includes padding and border inset.protected double
snappedRightInset()
Utility method to get the right inset which includes padding and border inset.protected double
snappedTopInset()
Utility method to get the top inset which includes padding and border inset.DoubleProperty
spacingProperty()
Specifies the spacing between menu buttons on the MenuBar.Methods inherited from class javafx.scene.control.SkinBase
computeBaselineOffset, computeMaxWidth, consumeMouseEvents, executeAccessibleAction, getChildren, getNode, getSkinnable, layoutInArea, layoutInArea, layoutInArea, positionInArea, positionInArea, pseudoClassStateChanged, registerChangeListener, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, unregisterChangeListeners
-
Property Details
-
spacing
Specifies the spacing between menu buttons on the MenuBar.- See Also:
getSpacing()
,setSpacing(double)
-
containerAlignment
Specifies the alignment of the menu buttons inside the MenuBar (by default it is Pos.TOP_LEFT).
-
-
Constructor Details
-
MenuBarSkin
Creates a new MenuBarSkin instance, installing the necessary child nodes into the Controlchildren
list, as well as the necessary input mappings for handling key, mouse, etc events.- Parameters:
control
- The control that this skin should be installed onto.
-
-
Method Details
-
setDefaultSystemMenuBar
Set the default system menu bar. This allows an application to keep menu in the system menu bar after the last Window is closed.- Parameters:
menuBar
- the menu bar
-
setSpacing
public final void setSpacing(double value)Sets the value of the property spacing.- Property description:
- Specifies the spacing between menu buttons on the MenuBar.
-
getSpacing
public final double getSpacing()Gets the value of the property spacing.- Property description:
- Specifies the spacing between menu buttons on the MenuBar.
-
spacingProperty
Specifies the spacing between menu buttons on the MenuBar.- See Also:
getSpacing()
,setSpacing(double)
-
setContainerAlignment
Sets the value of the property containerAlignment.- Property description:
- Specifies the alignment of the menu buttons inside the MenuBar (by default it is Pos.TOP_LEFT).
-
getContainerAlignment
Gets the value of the property containerAlignment.- Property description:
- Specifies the alignment of the menu buttons inside the MenuBar (by default it is Pos.TOP_LEFT).
-
containerAlignmentProperty
Specifies the alignment of the menu buttons inside the MenuBar (by default it is Pos.TOP_LEFT). -
dispose
public void dispose()Called by a Skinnable when the Skin is replaced on the Skinnable. This method allows a Skin to implement any logic necessary to clean up itself after the Skin is no longer needed. It may be used to release native resources. The methodsSkin.getSkinnable()
andSkin.getNode()
should return null following a call to dispose. Calling dispose twice has no effect. -
snappedTopInset
protected double snappedTopInset()Utility method to get the top inset which includes padding and border inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true.- Overrides:
snappedTopInset
in classSkinBase<MenuBar>
- Returns:
- Rounded up insets top
-
snappedBottomInset
protected double snappedBottomInset()Utility method to get the bottom inset which includes padding and border inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true.- Overrides:
snappedBottomInset
in classSkinBase<MenuBar>
- Returns:
- Rounded up insets bottom
-
snappedLeftInset
protected double snappedLeftInset()Utility method to get the left inset which includes padding and border inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true.- Overrides:
snappedLeftInset
in classSkinBase<MenuBar>
- Returns:
- Rounded up insets left
-
snappedRightInset
protected double snappedRightInset()Utility method to get the right inset which includes padding and border inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true.- Overrides:
snappedRightInset
in classSkinBase<MenuBar>
- Returns:
- Rounded up insets right
-
layoutChildren
protected void layoutChildren(double x, double y, double w, double h)Called during the layout pass of the scenegraph.- Overrides:
layoutChildren
in classSkinBase<MenuBar>
- Parameters:
x
- the x positiony
- the y positionw
- the widthh
- the height
-
computeMinWidth
protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)Computes the minimum allowable width of the Skin, based on the provided height.- Overrides:
computeMinWidth
in classSkinBase<MenuBar>
- Parameters:
height
- The height of the Skin, in case this value might dictate the minimum width.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left inset- Returns:
- A double representing the minimum width of this Skin.
-
computePrefWidth
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)Calculates the preferred width of thisSkinBase
. The default implementation calculates this width as the width of the area occupied by its managed children when they are positioned at their current positions at their preferred widths.- Overrides:
computePrefWidth
in classSkinBase<MenuBar>
- Parameters:
height
- the height that should be used if preferred width depends on ittopInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left inset- Returns:
- the calculated preferred width
-
computeMinHeight
protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)Computes the minimum allowable height of the Skin, based on the provided width.- Overrides:
computeMinHeight
in classSkinBase<MenuBar>
- Parameters:
width
- The width of the Skin, in case this value might dictate the minimum height.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left inset- Returns:
- A double representing the minimum height of this Skin.
-
computePrefHeight
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)Calculates the preferred height of thisSkinBase
. The default implementation calculates this height as the height of the area occupied by its managed children when they are positioned at their current positions at their preferred heights.- Overrides:
computePrefHeight
in classSkinBase<MenuBar>
- Parameters:
width
- the width that should be used if preferred height depends on ittopInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left inset- Returns:
- the calculated preferred height
-
computeMaxHeight
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)Computes the maximum allowable height of the Skin, based on the provided width.- Overrides:
computeMaxHeight
in classSkinBase<MenuBar>
- Parameters:
width
- The width of the Skin, in case this value might dictate the maximum height.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left inset- Returns:
- A double representing the maximum height of this Skin.
-
getClassCssMetaData
Returns the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.- Returns:
- the CssMetaData associated with this class, which may include the CssMetaData of its superclasses
-
getCssMetaData
This method should delegate toNode.getClassCssMetaData()
so that a Node's CssMetaData can be accessed without the need for reflection.- Overrides:
getCssMetaData
in classSkinBase<MenuBar>
- Returns:
- The CssMetaData associated with this node, which may include the CssMetaData of its superclasses.
-
queryAccessibleAttribute
This method is called by the assistive technology to request the value for an attribute.This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation must be called.- Overrides:
queryAccessibleAttribute
in classSkinBase<MenuBar>
- Parameters:
attribute
- the requested attributeparameters
- optional list of parameters- Returns:
- the value for the requested attribute
- See Also:
AccessibleAttribute
,Node.queryAccessibleAttribute(javafx.scene.AccessibleAttribute, java.lang.Object...)
-