public class RootMenuPiece extends NodeMenuPiece
| Constructor and Description |
|---|
RootMenuPiece()
Creates a new root-piece, using a normal
JMenu to inserts
its content. |
RootMenuPiece(JMenu menu)
Creates a new root-piece.
|
RootMenuPiece(String text,
boolean disableWhenEmpty,
MenuPiece... pieces)
Creates a new root-piece, using a normal
JMenu. |
| Modifier and Type | Method and Description |
|---|---|
JMenu |
getMenu()
Gets the menu into which this
MenuPiece adds its items. |
boolean |
isDisableWhenEmpty()
Whether to disable the menu when it is empty or not.
|
boolean |
isEnabled()
Tells whether the menu can be enabled or not.
|
void |
setDisableWhenEmpty(boolean disableWhenEmpty)
Disables the menu if there are no items in the menu.
|
void |
setEnabled(boolean enabled)
Enables or disables the menu.
|
void |
setParent(MenuPiece parent)
Sets the parent of this piece.
|
protected void |
updateEnabled()
Calls
JMenuItem.setEnabled(boolean) with a parameter that is calculated using
isDisableWhenEmpty(), NodeMenuPiece.getItemCount() and |
add, bind, fill, getChild, getChildrenCount, getItemCount, insert, remove, remove, unbindaddListener, fireInsert, fireRemove, getParent, isBound, items, removeListenerpublic RootMenuPiece()
JMenu to inserts
its content.public RootMenuPiece(String text, boolean disableWhenEmpty, MenuPiece... pieces)
JMenu.text - the text of the menudisableWhenEmpty - whether to disable the menu when it is emptypieces - the elements of this piecepublic RootMenuPiece(JMenu menu)
menu - the menu into which this piece will insert its contentprotected void updateEnabled()
JMenuItem.setEnabled(boolean) with a parameter that is calculated using
isDisableWhenEmpty(), NodeMenuPiece.getItemCount() andpublic void setDisableWhenEmpty(boolean disableWhenEmpty)
disableWhenEmpty - true if the menu should be
disabled when emptypublic boolean isDisableWhenEmpty()
true if the menu gets disabledsetEnabled(boolean)public void setEnabled(boolean enabled)
false, then the
menu is disabled in any case. Otherwise the menu may be enabled or disabled
depending on the value of isDisableWhenEmpty().enabled - wether the menu should be enabledsetEnabled(boolean)public boolean isEnabled()
true if the menu can be enabledpublic JMenu getMenu()
MenuPieceMenuPiece adds its items.Copyright © 2018. All rights reserved.