jcontrol.ui.vole.menu
Class Menu

java.lang.Object
  extended by jcontrol.ui.vole.Component
      extended by jcontrol.ui.vole.menu.Menu
All Implemented Interfaces:
MenuInterface
Direct Known Subclasses:
BigImageMenu, MenuBar, MultiImageMenu, TextMenu

public abstract class Menu
extends Component
implements MenuInterface

The abstract class Menu is the superclass for graphical menus.

(c) Copyright 2003-2007 DOMOLOGIC GmbH


Field Summary
protected  java.util.Vector m_inactive
           
protected  java.util.Vector m_items
           
protected  int m_lastSelectedIndex
           
protected  ActionListener m_listener
           
protected  boolean m_repaint
           
protected  int m_selectedIndex
           
 
Fields inherited from class jcontrol.ui.vole.Component
eventQueue, focusOwner, font, g, height, listener, parent, visible, width, x, y
 
Constructor Summary
Menu(int x, int y, int width, int height)
           
 
Method Summary
 int addMenuItem(String item)
          Adds a menu item to this menu.
 int addMenuItem(String item, int pos)
          Adds a menu item to this menu at the specified position.
 void enableMenuItem(String item, boolean onoff)
          Changes the active state of a menu item in this menu.
 int getActiveItemCount()
          Returns the number of active menu items.
 int getSelectedIndex()
          Returns the index of the selected menu item.
protected  boolean hasNextOrPrev(boolean updown, int index)
          Checks if the specified menu item has an active predecessor or successor.
 boolean isMenuItemEnabled(String item)
          Returns the active state of the specified menu item.
 boolean onKeyEvent(KeyEvent e)
          If a KeyEvent accurs, this method is called.
abstract  void paint()
          Paint has to be implemented by the deviating class.
 void remove()
          Removes this menu from the screen.
 void removeMenuItem(String item)
          Removes a menu item from this menu.
 boolean select(int index)
          Selects the specified menu item.
 boolean select(String item)
          Selects the specified menu item.
protected  int selectNextOrPrev(boolean updown)
          Selects the next or previous menu item in this menu.
 void setActionListener(ActionListener listener)
          Set the ActionListener for this menu.
 void setFont(Resource font)
          Set the font for this component.
 void setParent(Container parent)
          Sets the parent Container.
 
Methods inherited from class jcontrol.ui.vole.Component
getBounds, getParent, isVisible, onActionEvent, removeFocus, requestFocus, setBounds, setGraphics, setVisible, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 
Methods inherited from interface jcontrol.ui.vole.menu.MenuInterface
setGraphics
 

Field Detail

m_selectedIndex

protected int m_selectedIndex

m_lastSelectedIndex

protected int m_lastSelectedIndex

m_repaint

protected boolean m_repaint

m_items

protected java.util.Vector m_items

m_inactive

protected java.util.Vector m_inactive

m_listener

protected ActionListener m_listener
Constructor Detail

Menu

public Menu(int x,
            int y,
            int width,
            int height)
Method Detail

setFont

public void setFont(Resource font)
Set the font for this component.

Overrides:
setFont in class Component
Parameters:
font - The new font.

addMenuItem

public int addMenuItem(String item)
Adds a menu item to this menu.

Specified by:
addMenuItem in interface MenuInterface
Parameters:
item - the name of the menu item, can even specify an image name
Returns:
the index of the new menu item

setParent

public void setParent(Container parent)
Sets the parent Container.

Specified by:
setParent in interface MenuInterface
Overrides:
setParent in class Component
Parameters:
parent - the Container to be the parent Object

addMenuItem

public int addMenuItem(String item,
                       int pos)
Adds a menu item to this menu at the specified position.

Specified by:
addMenuItem in interface MenuInterface
Parameters:
item - the name of the menu item, can even specify an image name
pos - the position
Returns:
the index of the new menu item

removeMenuItem

public void removeMenuItem(String item)
Removes a menu item from this menu.

Specified by:
removeMenuItem in interface MenuInterface
Parameters:
item - the item to remove

getActiveItemCount

public int getActiveItemCount()
Returns the number of active menu items.

Specified by:
getActiveItemCount in interface MenuInterface
Returns:
The numer of active menu items.

enableMenuItem

public void enableMenuItem(String item,
                           boolean onoff)
Changes the active state of a menu item in this menu.

Specified by:
enableMenuItem in interface MenuInterface
Parameters:
item - the name to the menu item
onoff - enable or disable

isMenuItemEnabled

public boolean isMenuItemEnabled(String item)
Returns the active state of the specified menu item.

Specified by:
isMenuItemEnabled in interface MenuInterface
Parameters:
item - the menu item
Returns:
boolean the active state of the menu item

getSelectedIndex

public int getSelectedIndex()
Returns the index of the selected menu item.

Specified by:
getSelectedIndex in interface MenuInterface
Returns:
The index of the selected menu item.

select

public boolean select(int index)
Selects the specified menu item.

Specified by:
select in interface MenuInterface
Parameters:
index - the index of the item to select
Returns:
boolean true if the item has been selected successfully, false otherwise

select

public boolean select(String item)
Selects the specified menu item.

Specified by:
select in interface MenuInterface
Parameters:
item - the item to select
Returns:
boolean true if the item has been selected successfully, false otherwise

selectNextOrPrev

protected int selectNextOrPrev(boolean updown)
Selects the next or previous menu item in this menu.

Parameters:
updown - if true, select the next item, the previous otherwise
Returns:
int the index of the selected menu item

hasNextOrPrev

protected boolean hasNextOrPrev(boolean updown,
                                int index)
Checks if the specified menu item has an active predecessor or successor.

Parameters:
updown - if true, check for a successor, for a predecessor otherwise
index - the index of the menu item
Returns:
true if the specified menu item has an active successor/predecessor, false otherwise.

paint

public abstract void paint()
Paint has to be implemented by the deviating class.

Specified by:
paint in interface MenuInterface
Overrides:
paint in class Component
See Also:
paint()

remove

public void remove()
Removes this menu from the screen.

Specified by:
remove in interface MenuInterface
Overrides:
remove in class Component

setActionListener

public void setActionListener(ActionListener listener)
Set the ActionListener for this menu. It will receive action events when a menu item is selected.

Parameters:
listener - The action listener to associate with this menu.

onKeyEvent

public boolean onKeyEvent(KeyEvent e)
If a KeyEvent accurs, this method is called.

Specified by:
onKeyEvent in interface MenuInterface
Overrides:
onKeyEvent in class Component
Parameters:
e - The KeyEvent.
Returns:
false if the KeyEvent was consumed, true otherwise.