public class MenuBar extends Control
A MenuBar control traditionally is placed at the very top of the user
interface, and embedded within it are Menus
. To add a menu to
a menubar, you add it to the menus
ObservableList.
By default, for each menu added to the menubar, it will be
represented as a button with the Menu text
value displayed.
MenuBar sets focusTraversable to false.
To create and populate aMenuBar
, you may do what is shown below.
Please refer to the Menu
API page for more information on how to
configure it.
final Menu menu1 = new Menu("File");
final Menu menu2 = new Menu("Options");
final Menu menu3 = new Menu("Help");
MenuBar menuBar = new MenuBar();
menuBar.getMenus().addAll(menu1, menu2, menu3);
Type | Property and Description |
---|---|
BooleanProperty |
useSystemMenuBar
Use the system menu bar if the current platform supports it.
|
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
Modifier and Type | Class and Description |
---|---|
private static class |
MenuBar.StyleableProperties |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
BIND_MSG |
private static java.lang.String |
DEFAULT_STYLE_CLASS
*
Stylesheet Handling *
*
|
private <any> |
menus
*
Instance variables *
*
|
private BooleanProperty |
useSystemMenuBar |
Constructor and Description |
---|
MenuBar()
Creates a new empty MenuBar.
|
MenuBar(Menu... menus)
Creates a new MenuBar populated with the given menus.
|
Modifier and Type | Method and Description |
---|---|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
static java.util.List<<any>> |
getClassCssMetaData() |
java.util.List<<any>> |
getControlCssMetaData() |
protected java.lang.Boolean |
getInitialFocusTraversable()
Returns the initial focus traversable state of this control, for use
by the JavaFX CSS engine to correctly set its initial value.
|
<any> |
getMenus()
The menus to show within this MenuBar.
|
boolean |
isUseSystemMenuBar()
Gets the value of the property useSystemMenuBar.
|
void |
setUseSystemMenuBar(boolean value)
Sets the value of the property useSystemMenuBar.
|
BooleanProperty |
useSystemMenuBarProperty()
Use the system menu bar if the current platform supports it.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getControlChildren, getCssMetaData, getSkin, getTooltip, isResizable, layoutChildren, loadSkinClass, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
public final BooleanProperty useSystemMenuBarProperty
isUseSystemMenuBar()
,
setUseSystemMenuBar(boolean)
private <any> menus
private java.lang.String BIND_MSG
private BooleanProperty useSystemMenuBar
private static final java.lang.String DEFAULT_STYLE_CLASS
public MenuBar()
public MenuBar(Menu... menus)
menus
- The menus to place inside the MenuBarpublic final BooleanProperty useSystemMenuBarProperty()
isUseSystemMenuBar()
,
setUseSystemMenuBar(boolean)
public final void setUseSystemMenuBar(boolean value)
public final boolean isUseSystemMenuBar()
public final <any> getMenus()
Menu
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class Control
public static java.util.List<<any>> getClassCssMetaData()
public java.util.List<<any>> getControlCssMetaData()
getControlCssMetaData
in class Control
protected java.lang.Boolean getInitialFocusTraversable()
getInitialFocusTraversable
in class Control