public class AwtMenuWrapper extends MenuWrapper
Modifier and Type | Field and Description |
---|---|
private java.awt.MenuItem[] |
items |
private java.awt.event.ActionListener |
listener |
private java.awt.MenuBar |
menuBar |
Constructor and Description |
---|
AwtMenuWrapper(Strings strings,
java.awt.event.ActionListener actionListener)
Internally creates a MenuBar object and provides methods to update that
menu bar.
|
Modifier and Type | Method and Description |
---|---|
private java.awt.Menu |
createMenu(Strings strings,
int stringIndex) |
private java.awt.MenuShortcut |
createMenuShortcut(int menuIndex) |
int |
findIndex(java.lang.Object o)
Attempts to find one of the menu items in the internal list.
|
java.awt.MenuBar |
getMenuBar()
Returns the encapsulated MenuBar object.
|
private void |
init(Strings strings)
Initializes an object of type MenuBar.
|
void |
setEnabled(int index,
boolean enabled)
Changes the enabled status of one of the MenuItem objects,
given by its index.
|
void |
setLabel(int index,
java.lang.String text)
Changes the label text of one of the MenuItem objects,
given by its index.
|
void |
updateEnabled(OperationProcessor op)
Changes the enabled status of all MenuItem objects
using the argument OperationProcessor object (more
precisely, its isAvailable(int) method).
|
void |
updateLabels(Strings strings)
Sets the label text of all MenuItem objects to
new values using the argument Strings information.
|
getStringIndex
private java.awt.event.ActionListener listener
private java.awt.MenuItem[] items
private java.awt.MenuBar menuBar
public AwtMenuWrapper(Strings strings, java.awt.event.ActionListener actionListener)
strings
- String resource used to initialize menu itemsactionListener
- a listener which will be registered with all menu itemsprivate java.awt.Menu createMenu(Strings strings, int stringIndex)
private java.awt.MenuShortcut createMenuShortcut(int menuIndex)
public int findIndex(java.lang.Object o)
findIndex
in class MenuWrapper
o
- some object representing part of the menuMenuIndexConstants
on success
or -1 on failurepublic java.awt.MenuBar getMenuBar()
private void init(Strings strings)
public void setEnabled(int index, boolean enabled)
setEnabled
in class MenuWrapper
index
- menu index of the component whose status is to be resetenabled
- boolean with the new valuepublic void setLabel(int index, java.lang.String text)
setLabel
in class MenuWrapper
index
- integer index of the menu elementtext
- new text value to be used for this elementpublic void updateEnabled(OperationProcessor op)
public void updateLabels(Strings strings)