bibliothek.gui.dock.facile.menu
Class SubmenuPiece

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

public class SubmenuPiece
extends MenuPiece

A MenuPiece which consists only of one JMenu. There is a new subtree attached to this SubmenuPiece.

Author:
Benjamin Sigg

Constructor Summary
SubmenuPiece()
          Creates a new submenu-piece, using a normal JMenu to inserts its content.
SubmenuPiece(JMenu menu)
          Creates a new submenu-piece.
SubmenuPiece(String text, boolean disableWhenEmpty, MenuPiece... pieces)
          Creates a new submenu-piece, using a normal JMenu.
 
Method Summary
 void bind()
          This method is called if there is a possibility for the user to see this menu.
 void fill(List<Component> items)
          Inserts all items of this piece into items.
 int getItemCount()
          Gets the number of items this MenuPiece added to its menu.
 JMenu getMenu()
          Gets the menu into which this MenuPiece adds its items.
 RootMenuPiece getRoot()
          Gets the root of this subtree.
 boolean isDisableWhenEmpty()
          Whether to disable the menu when it is empty or not.
 void setDisableWhenEmpty(boolean disableWhenEmpty)
          Disables the menu if there are no items in the menu.
 void unbind()
          This method is called if the user has no longer any possibility to see this menu.
 
Methods inherited from class bibliothek.gui.dock.support.menu.MenuPiece
addListener, fireInsert, fireRemove, getParent, isBound, items, removeListener, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubmenuPiece

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


SubmenuPiece

public SubmenuPiece(String text,
                    boolean disableWhenEmpty,
                    MenuPiece... pieces)
Creates a new submenu-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

SubmenuPiece

public SubmenuPiece(JMenu menu)
Creates a new submenu-piece.

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

bind

public void bind()
Description copied from class: MenuPiece
This method is called if there is a possibility for the user to see this menu. The menu should register listeners, update its text etc. to be ready for that event. This method must never be called twice in a row.

Overrides:
bind in class MenuPiece
See Also:
MenuPiece.unbind()

unbind

public void unbind()
Description copied from class: MenuPiece
This method is called if the user has no longer any possibility to see this menu. The menu should unregister its listeners. This method must never be called twice in a row.

Overrides:
unbind in class MenuPiece
See Also:
MenuPiece.bind()

fill

public void fill(List<Component> items)
Description copied from class: MenuPiece
Inserts all items of this piece into items.

Specified by:
fill in class MenuPiece
Parameters:
items - the list which has to be filled in the same order as the items will appear on the menu

getItemCount

public int getItemCount()
Description copied from class: MenuPiece
Gets the number of items this MenuPiece added to its menu.

Specified by:
getItemCount in class MenuPiece
Returns:
the number of items

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

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

getRoot

public RootMenuPiece getRoot()
Gets the root of this subtree.

Returns:
the root