bibliothek.gui.dock.facile.menu
Class RootMenuPiece

java.lang.Object
  extended by bibliothek.gui.dock.support.menu.MenuPiece
      extended by bibliothek.gui.dock.facile.menu.NodeMenuPiece
          extended by bibliothek.gui.dock.facile.menu.RootMenuPiece

public class RootMenuPiece
extends NodeMenuPiece

The root of a tree of MenuPieces. This MenuPiece is a direct representation of a JMenu

Author:
Benjamin Sigg

Constructor Summary
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.
 
Method Summary
 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
 
Methods inherited from class bibliothek.gui.dock.facile.menu.NodeMenuPiece
add, bind, fill, getChild, getChildrenCount, getItemCount, insert, remove, remove, unbind
 
Methods inherited from class bibliothek.gui.dock.support.menu.MenuPiece
addListener, fireInsert, fireRemove, getParent, isBound, items, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RootMenuPiece

public RootMenuPiece()
Creates a new root-piece, using a normal JMenu to inserts its content.


RootMenuPiece

public RootMenuPiece(String text,
                     boolean disableWhenEmpty,
                     MenuPiece... pieces)
Creates a new root-piece, using a normal JMenu.

Parameters:
text - the text of the menu
disableWhenEmpty - whether to disable the menu when it is empty
pieces - the elements of this piece

RootMenuPiece

public RootMenuPiece(JMenu menu)
Creates a new root-piece.

Parameters:
menu - the menu into which this piece will insert its content
Method Detail

updateEnabled

protected void updateEnabled()
Calls JMenuItem.setEnabled(boolean) with a parameter that is calculated using isDisableWhenEmpty(), NodeMenuPiece.getItemCount() and


setDisableWhenEmpty

public void setDisableWhenEmpty(boolean disableWhenEmpty)
Disables the menu if there are no items in the menu.

Parameters:
disableWhenEmpty - true if the menu should be disabled when empty

isDisableWhenEmpty

public boolean isDisableWhenEmpty()
Whether to disable the menu when it is empty or not.

Returns:
true if the menu gets disabled
See Also:
setEnabled(boolean)

setEnabled

public void setEnabled(boolean enabled)
Enables or disables the menu. If the argument is false, then the menu is disabled in any case. Otherwise the menu may be enabled or disabled depending on the value of isDisableWhenEmpty().

Parameters:
enabled - wether the menu should be enabled
See Also:
setEnabled(boolean)

isEnabled

public boolean isEnabled()
Tells whether the menu can be enabled or not.

Returns:
true if the menu can be enabled

getMenu

public JMenu getMenu()
Description copied from class: MenuPiece
Gets the menu into which this MenuPiece adds its items.

Overrides:
getMenu in class MenuPiece
Returns:
the menu

setParent

public void setParent(MenuPiece parent)
Description copied from class: MenuPiece
Sets the parent of this piece. Note that clients normally do not need to invoke this method.

Overrides:
setParent in class MenuPiece
Parameters:
parent - the parent, might be null