public abstract class MenuPiece extends Object
JMenu, can add or remove JMenuItems
or other JComponents 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(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()
|
JMenu |
getMenu()
Gets the menu into which this
MenuPiece adds its items. |
MenuPiece |
getParent()
Gets the parent of this piece.
|
boolean |
isBound()
|
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,
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 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 nullpublic void bind()
unbind()public void unbind()
bind()public boolean isBound()
public abstract int getItemCount()
public abstract void fill(List<Component> items)
items.items - the list which has to be filled in the same order as the items
will appear on the menupublic Component[] items()
Copyright © 2018. All rights reserved.