public abstract class MenuPiece
extends java.lang.Object
JMenu
, can add or remove JMenuItem
s
or other JComponent
s at any time to the menu.Constructor and Description |
---|
MenuPiece() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(MenuPieceListener listener)
Adds a listener to this piece, the listener will get informed when the
children of this piece change.
|
void |
bind()
This method is called if there is a possibility for the user to see this menu.
|
abstract void |
fill(java.util.List<java.awt.Component> items)
Inserts all items of this piece into
items . |
protected void |
fireInsert(int index,
java.awt.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()
|
javax.swing.JMenu |
getMenu()
Gets the menu into which this
MenuPiece adds its items. |
MenuPiece |
getParent()
Gets the parent of this piece.
|
boolean |
isBound()
|
java.awt.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.
|
void |
unbind()
This method is called if the user has no longer any possibility to see this menu.
|
public void addListener(MenuPieceListener listener)
listener
- the new listenerpublic void removeListener(MenuPieceListener listener)
listener
from this piece.listener
- the listener to removeprotected void fireInsert(int index, java.awt.Component... items)
index
- the index of the first new itemitems
- the new itemsprotected void fireRemove(int index, int length)
index
- the index of the first deleted itemlength
- the number of deleted itemspublic javax.swing.JMenu getMenu()
MenuPiece
adds its items.public MenuPiece getParent()
null
for the root or for a piece
which is not yet integrated.public void setParent(MenuPiece parent)
parent
- the parent, might be null
public void bind()
unbind()
public void unbind()
bind()
public boolean isBound()
public abstract int getItemCount()
public abstract void fill(java.util.List<java.awt.Component> items)
items
.items
- the list which has to be filled in the same order as the items
will appear on the menupublic java.awt.Component[] items()