net.sourceforge.jiu.gui.awt

Class AwtMenuWrapper


public class AwtMenuWrapper
extends MenuWrapper

A wrapper around an AWT MenuBar object.
Author:
Marco Schmidt
Since:
0.8.0

Field Summary

private MenuItem[]
items
private ActionListener
listener
private MenuBar
menuBar

Constructor Summary

AwtMenuWrapper(Strings strings, ActionListener actionListener)
Internally creates a MenuBar object and provides methods to update that menu bar.

Method Summary

private Menu
createMenu(Strings strings, int stringIndex)
private MenuShortcut
createMenuShortcut(int menuIndex)
int
findIndex(Object o)
Attempts to find one of the menu items in the internal list.
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, 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.

Methods inherited from class net.sourceforge.jiu.apps.MenuWrapper

findIndex, getStringIndex, setEnabled, setLabel

Field Details

items

private MenuItem[] items

listener

private ActionListener listener

menuBar

private MenuBar menuBar

Constructor Details

AwtMenuWrapper

public AwtMenuWrapper(Strings strings,
                      ActionListener actionListener)
Internally creates a MenuBar object and provides methods to update that menu bar.
Parameters:
strings - String resource used to initialize menu items
actionListener - a listener which will be registered with all menu items

Method Details

createMenu

private Menu createMenu(Strings strings,
                        int stringIndex)

createMenuShortcut

private MenuShortcut createMenuShortcut(int menuIndex)

findIndex

public int findIndex(Object o)
Attempts to find one of the menu items in the internal list. Returns its index or -1 if it is not one of the items.
Overrides:
findIndex in interface MenuWrapper

getMenuBar

public MenuBar getMenuBar()
Returns the encapsulated MenuBar object.

init

private void init(Strings strings)
Initializes an object of type MenuBar.

setEnabled

public void setEnabled(int index,
                       boolean enabled)
Changes the enabled status of one of the MenuItem objects, given by its index.
Overrides:
setEnabled in interface MenuWrapper

setLabel

public void setLabel(int index,
                     String text)
Changes the label text of one of the MenuItem objects, given by its index.
Overrides:
setLabel in interface MenuWrapper

updateEnabled

public void updateEnabled(OperationProcessor op)
Changes the enabled status of all MenuItem objects using the argument OperationProcessor object (more precisely, its isAvailable(int) method).

updateLabels

public void updateLabels(Strings strings)
Sets the label text of all MenuItem objects to new values using the argument Strings information.