Package bibliothek.gui.dock.support.menu
Class MenuPiece
java.lang.Object
bibliothek.gui.dock.support.menu.MenuPiece
- Direct Known Subclasses:
BaseMenuPiece,NodeMenuPiece,SeparatingMenuPiece,SubmenuPiece
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(MenuPieceListener listener) Adds a listener to this piece, the listener will get informed when the children of this piece change.voidbind()This method is called if there is a possibility for the user to see this menu.abstract voidInserts all items of this piece intoitems.protected voidfireInsert(int index, Component... items) Informs all listeners that new items were inserted.protected voidfireRemove(int index, int length) Informs all listeners that items were deleted.abstract intgetMenu()Gets the menu into which thisMenuPieceadds its items.Gets the parent of this piece.booleanisBound()items()Gets all items that are shown by this piece.voidremoveListener(MenuPieceListener listener) Removeslistenerfrom this piece.voidSets the parent of this piece.voidunbind()This method is called if the user has no longer any possibility to see this menu.
-
Constructor Details
-
MenuPiece
public MenuPiece()
-
-
Method Details
-
fireInsert
Informs all listeners that new items were inserted.- Parameters:
index- the index of the first new itemitems- 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 itemlength- the number of deleted items
-
getMenu
Gets the menu into which thisMenuPieceadds its items.- Returns:
- the menu
-
getParent
Gets the parent of this piece.- Returns:
- the parent, can be
nullfor the root or for a piece which is not yet integrated.
-
bind
public void bind()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.- See Also:
-
unbind
public void unbind()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.- See Also:
-
isBound
public boolean isBound()- Returns:
- whether this menu piece may be visible to the user
-
getItemCount
public abstract int getItemCount()- Returns:
- the number of items
-
fill
Inserts all items of this piece intoitems.- Parameters:
items- the list which has to be filled in the same order as the items will appear on the menu
-
items
Gets all items that are shown by this piece.- Returns:
- all items