extra.ui
Class Menu

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--extra.ui.Menu

public class Menu
extends Control

This is a standard palm menu. Use this Menu with MenuBar. A large amaount of code was stolen from List.


Constructor Summary
Menu()
          Construct a new empty menu of default size
Menu(String[] items)
          Construct a new menu with the given items.
Menu(Vector items)
          Construct a new menu
 
Method Summary
 void add(String name)
          Add a new item to the end of the menu.
 boolean calcSizes()
           
 void drawList(Graphics g)
           
 String getSelected()
          Gets the text of the currently selected item
 int getSelectedIndex()
          Get the index of the currently selected item
 void hide()
          Hide the menu
 void onEvent(Event event)
          Process pen and key events to this component
 void onPaint(Graphics g)
          Called to draw the control.
 void setSelectedIndex(int i)
          Sets the currently selected index
 void show(int x)
          Show this menu up
 
Methods inherited from class waba.ui.Control
addTimer, contains, createGraphics, getFontMetrics, getNext, getParent, getRect, postEvent, removeTimer, repaint, setRect
 
Methods inherited from class java.lang.Object
equals, hashCode, toString
 

Constructor Detail

Menu

public Menu()
Construct a new empty menu of default size

Menu

public Menu(Vector items)
Construct a new menu
Parameters:
options - an array of the items available

Menu

public Menu(String[] items)
Construct a new menu with the given items. The first item defines the name of the menu. To insert a separator simply add an option "-" to the menu.
Parameters:
options - an array of the menu items available
Method Detail

add

public void add(String name)
Add a new item to the end of the menu. The first item defines the name of the menu. To insert a separator simply add an option "-" to the menu.
Parameters:
name - the item to add

getSelected

public String getSelected()
Gets the text of the currently selected item

getSelectedIndex

public int getSelectedIndex()
Get the index of the currently selected item

setSelectedIndex

public void setSelectedIndex(int i)
Sets the currently selected index
Parameters:
i - the index of the item to select

calcSizes

public boolean calcSizes()

onPaint

public void onPaint(Graphics g)
Description copied from class: Control
Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted. The background is painted by the top-level window control.
Overrides:
onPaint in class Control
Following copied from class: waba.ui.Control
Parameters:
g - the graphics object for drawing
See Also:
Graphics

drawList

public void drawList(Graphics g)

show

public void show(int x)
Show this menu up
Parameters:
x - the x-position to start the menu

hide

public void hide()
Hide the menu

onEvent

public void onEvent(Event event)
Process pen and key events to this component
Overrides:
onEvent in class Control
Parameters:
event - the event to process