bibliothek.gui.dock.support.menu
Class MenuPiece

java.lang.Object
  extended by bibliothek.gui.dock.support.menu.MenuPiece
Direct Known Subclasses:
BaseMenuPiece, NodeMenuPiece, SeparatingMenuPiece, SubmenuPiece

public abstract class MenuPiece
extends Object

Describes a part of a JMenu, can add or remove JMenuItems or other JComponents at any time to the menu.

Author:
Benjamin Sigg

Constructor Summary
MenuPiece()
           
 
Method Summary
 void addListener(MenuPieceListener listener)
          Adds a listener to this piece, the listener will get informed when the children of this piece change.
abstract  void fill(List<Component> items)
          Inserts all items of this piece into items.
protected  void fireInsert(int index, Component... items)
          Informs all listeners that new items were inserted.
protected  void fireRemove(int index, int length)
          Informs all listeners that items were deleted.
abstract  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.
 MenuPiece getParent()
          Gets the parent of this piece.
 Component[] items()
          Gets all items that are shown by this piece.
 void removeListener(MenuPieceListener listener)
          Removes listener from this piece.
 void setParent(MenuPiece parent)
          Sets the parent of this piece.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuPiece

public MenuPiece()
Method Detail

addListener

public void addListener(MenuPieceListener listener)
Adds a listener to this piece, the listener will get informed when the children of this piece change.

Parameters:
listener - the new listener

removeListener

public void removeListener(MenuPieceListener listener)
Removes listener from this piece.

Parameters:
listener - the listener to remove

fireInsert

protected void fireInsert(int index,
                          Component... items)
Informs all listeners that new items were inserted.

Parameters:
index - the index of the first new item
items - the new items

fireRemove

protected void fireRemove(int index,
                          int length)
Informs all listeners that items were deleted.

Parameters:
index - the index of the first deleted item
length - the number of deleted items

getMenu

public JMenu getMenu()
Gets the menu into which this MenuPiece adds its items.

Returns:
the menu

getParent

public MenuPiece getParent()
Gets the parent of this piece.

Returns:
the parent, can be null for the root or for a piece which is not yet integrated.

setParent

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

Parameters:
parent - the parent, might be null

getItemCount

public abstract int getItemCount()
Gets the number of items this MenuPiece added to its menu.

Returns:
the number of items

fill

public abstract void fill(List<Component> items)
Inserts all items of this piece into items.

Parameters:
items - the list which has to be filled in the same order as the items will appear on the menu

items

public Component[] items()
Gets all items that are shown by this piece.

Returns:
all items