Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.ui.wombat.menu
Class Menu

    java.lang.Object
      jcontrol.ui.wombat.Component
          jcontrol.ui.wombat.AbstractFocusComponent
              jcontrol.ui.wombat.menu.Menu

All Implemented Interfaces:
  EventListener, ActionProducer, KeyListener, TouchListener, IFocusable

Direct Known Subclasses:
  MultiImageMenu

    public abstract class Menu

extends AbstractFocusComponent

The abstract class `Menu` is the superclass for graphical menus.

(c) Copyright 2005-2007 DOMOLOGIC GmbH

Field Summary
`protected boolean[]` | `m_inactives`
`protected Object[]` | `m_items`
`protected int` | `m_scrollValue`
`protected int` | `m_selectedIndex`

Fields inherited from class jcontrol.ui.wombat.AbstractFocusComponent
`BORDER_WIDTH, listener`

Fields inherited from class jcontrol.ui.wombat.Component
`backgroundColor, COLOR_COMPONENT_BACKGROUND, COLOR_COMPONENT_BACKGROUND_HIGHLIGHTED, COLOR_COMPONENT_DARK_SHADOW, COLOR_COMPONENT_FOREGROUND, COLOR_COMPONENT_FOREGROUND_INACTIVE, COLOR_COMPONENT_HIGHLIGHT_SHADOW, COLOR_COMPONENT_LIGHT_SHADOW, COLOR_COMPONENT_LIST_BACKGROUND, COLOR_COMPONENT_NORMAL_SHADOW, COLOR_COMPONENT_SELECTION_TEXT, COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND, COLOR_COMPONENT_SELECTION_TEXT_BACKGROUND_INACTIVE, COLOR_COMPONENT_SELECTION_TEXT_INACTIVE, eventQueue, font, foregroundColor, frame, height, parent, RESERVED1, RESERVED2, RESERVED3, RESERVED4, RESERVED5, RESERVED6, state, STATE_ABORT_UPDATE, STATE_ANIMATED, STATE_BG_COLOR_SET, STATE_COVERED, STATE_DIRTY_MASK, STATE_DIRTY_PAINTALL, STATE_DIRTY_REPAINT, STATE_DIRTY_UPDATE, STATE_DISABLED, STATE_DISPOSED, STATE_FG_COLOR_SET, STATE_FOCUS, STATE_HEIGHT_FIXED, STATE_NO_REDRAW, STATE_REVALIDATE, STATE_SELECTED, STATE_SIZE_FIXED, STATE_UPDATED, STATE_VISIBLE, STATE_WIDTH_FIXED, transparentColor, width, x, y`

Fields inherited from interface jcontrol.ui.wombat.IFocusable
`TRANSFER_FOCUS_BACKWARD, TRANSFER_FOCUS_FORWARD`

Fields inherited from interface jcontrol.ui.wombat.event.TouchListener
`RESULT_ACCEPTED, RESULT_EXECUTED, RESULT_NONE`

Constructor Summary
`Menu(String[] items, int x, int y, int width, int height)`

Method Summary
`abstract int` | `addMenuItem(String item)` Adds a menu item to this menu.
`int` | `getIndex(String item)` Returns the index of the specified item or `-1` if there is no such item in this menu.
`String` | `getItem(int index)` Returns the item at the specified index or `null` if the index is out of range.
`int` | `getItemCount()` Returns the number of menu items.
`int` | `getSelectedIndex()` Returns the index of the selected menu item or -1 if none is selected.
`abstract int` | `insertMenuItem(String item, int index)` Inserts a menu item at the specified position.
`abstract boolean` | `removeMenuItem(int index)` Removes a menu at the specified index item from this menu.
`protected boolean` | `selectNextOrPrev(boolean updown)` Selects the next or previous menu item in this menu.
`void` | `setEnabled(int index, boolean enabled)` Enables or disables the menu item at the specified index.
`boolean` | `setSelection(int index)` Selects the item at the given zero-relative index in the receiver's list.

Methods inherited from class jcontrol.ui.wombat.AbstractFocusComponent
`clearCorners, drawBevelRect, drawButton, drawDottedRect, drawFocusRect, getActionListener, onActionEvent, onKeyEvent, onTouchEvent, requestFocus, setActionListener, setEnabled, setVisible`

Methods inherited from class jcontrol.ui.wombat.Component
`drawDisabledImage, getFrame, isEnabled, isVisible, isVisibleInternal, paint, redrawInternalAndParent, repaint, repaintAll, safeExec, setBackgroundColor, setBackgroundColorInternal, setBounds, setDirty, setFont, setForegroundColor, setForegroundColorInternal, setParametersInternal, setRedraw, setTransparentColor, unsafeExec, update`

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Field Detail

### m_selectedIndex

    protected int m_selectedIndex

### m_scrollValue

    protected int m_scrollValue

### m_items

    protected Object[] m_items

### m_inactives

    protected boolean[] m_inactives

Constructor Detail

### Menu

    public Menu(String[] items,
                int x,
                int y,
                int width,
                int height)

Method Detail

### addMenuItem

    public abstract int addMenuItem(String item)

  Adds a menu item to this menu. This method should be used with care. Initializing a menu with a list of menu items should always be done via the constructor instead. Adding or removing items in a menu will cause an array copy which may lead to a lot of memory consumption for a short period of time.

  Parameters:
    `item` - the name of the menu item, can even specify an image name
  Returns:
    the index of the new menu item
  See Also:
    `insertMenuItem(String, int)`

### insertMenuItem

    public abstract int insertMenuItem(String item,
                                       int index)

  Inserts a menu item at the specified position. This method should be used with care. Initializing a menu with a list of menu items should always be done via the constructor instead. Adding or removing items in a menu will cause an array copy which may lead to a lot of memory consumption for a short period of time.

  Parameters:
    `item` - the name of the menu item, can even specify an image name
    `index` - the position
  Returns:
    the index of the new menu item
  See Also:
    `addMenuItem(String)`

### removeMenuItem

    public abstract boolean removeMenuItem(int index)

  Removes a menu at the specified index item from this menu. This method should be used with care. Adding or removing items in a menu will cause an array copy which may lead to a lot of memory consumption for a short period of time. If a menu item should be removed temporary it should better be disabled using the `setEnabled(int, boolean)` method instead.

  Parameters:
    `index` - the index to remove
  Returns:
    boolean `true` if the item has been removed successfully, `false` otherwise
  See Also:
    `setEnabled(int, boolean)`

### setEnabled

    public void setEnabled(int index,
                           boolean enabled)

  Enables or disables the menu item at the specified index. A disabled menu item is not selectable from the user interface and draws with an inactive or "grayed" look.

  Parameters:
    `index` - the index to enable or disable
    `enabled` - the new enabled state

### getItemCount

    public int getItemCount()

  Returns the number of menu items.

  Returns:
    The numer of menu items.

### getSelectedIndex

    public int getSelectedIndex()

  Returns the index of the selected menu item or -1 if none is selected.

  Returns:
    The index of the selected menu item.

### getItem

    public String getItem(int index)

  Returns the item at the specified index or `null` if the index is out of range.

  Parameters:
    `index` - the index
  Returns:
    the item at the specified index

### getIndex

    public int getIndex(String item)

  Returns the index of the specified item or `-1` if there is no such item in this menu.

  Parameters:
    `item` - the item to search for
  Returns:
    the index of the specified item

### setSelection

    public boolean setSelection(int index)

  Selects the item at the given zero-relative index in the receiver's list. If the item at the index was already selected, it remains selected. Indices that are out of range are ignored.

  Parameters:
    `index` - the index of the item to select
  Returns:
    boolean `true` if the item has been selected successfully, `false` otherwise

### selectNextOrPrev

    protected boolean 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:
    true if the selection has changed

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD