brf.j2me.dynaworks.ui
Class ComboBox

java.lang.Object
  |
  +--brf.j2me.dynaworks.ui.BasicWidget
        |
        +--brf.j2me.dynaworks.ui.ComboBox
All Implemented Interfaces:
UserWidget

public class ComboBox
extends BasicWidget

Custom user control widget for a combobox.

Version:
1.0
Author:
Bernd R. Fix
See Also:
BasicWidget, UserWidget

Field Summary
private  boolean expanded
          selection list visible?
private  int he
          height of expanded selection.
private  int idx
          index of selected entry.
private  ListBox lb
          associated listbox.
private static Bitmap select
          Bitmap "select"
private  java.lang.String text
          Label of the combobox.
private  int ye
          y-position for expanded selection.
 
Fields inherited from class brf.j2me.dynaworks.ui.BasicWidget
g, h, w, x, y
 
Constructor Summary
ComboBox(int x, int y, int w, int exp)
          constructor.
 
Method Summary
(package private) static void ()
           
 void addItem(ListItem item)
          Inserts the item for selection.
 boolean contains(int xc, int yc)
          check if point is inside the widget
 int getSelection()
          get the index of the currently selected entry.
 java.lang.String getSelectionText()
          get the text of the currently selected entry.
 ActionEvent handleKeyDown(int keyCode)
          Handle a "keyDown" event.
 ActionEvent handlePenDown(int xc, int yc)
          Handle a "pen down" event.
 ActionEvent handlePenMove(int xc, int yc)
          Handle a "pen move" event.
 ActionEvent handlePenUp(int xc, int yc)
          Handle a "pen up" event.
 void paint()
          Paint the user control.
 void removeAll()
          deletes all items from the selection list.
 boolean removeItem(ListItem item)
          Deletes the item from the selection list.
 void selectItem(ListItem item, boolean redraw)
          selects the item.
 void setExpanded(boolean mode)
          set the expanded mode of the combobox.
 
Methods inherited from class brf.j2me.dynaworks.ui.BasicWidget
handleSysKeyDown, hasFocus, loseFocus, setFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

ye

private int ye
y-position for expanded selection.


he

private int he
height of expanded selection.


expanded

private boolean expanded
selection list visible?


lb

private ListBox lb
associated listbox.


text

private java.lang.String text
Label of the combobox.


idx

private int idx
index of selected entry.


select

private static Bitmap select
Bitmap "select"

Constructor Detail

ComboBox

public ComboBox(int x,
                int y,
                int w,
                int exp)
constructor.

Parameters:
x - int - x coordinate of upper-left corner.
y - int - y coordinate of upper-left corner.
w - int - width of control.
exp - int - height of control when expanded.
Method Detail

static void ()

contains

public boolean contains(int xc,
                        int yc)
check if point is inside the widget

Overrides:
contains in class BasicWidget
Parameters:
xc - int - x coordinate of check point.
yc - int - y coordinate of check point.
Returns:
boolean - point inside control?

addItem

public void addItem(ListItem item)
Inserts the item for selection.

Parameters:
item - ListItem - item to be inserted.

removeItem

public boolean removeItem(ListItem item)
Deletes the item from the selection list.

Parameters:
item - ListItem - item to be removed
Returns:
true if the argument was part of the list; false otherwise

removeAll

public void removeAll()
deletes all items from the selection list.


selectItem

public void selectItem(ListItem item,
                       boolean redraw)
selects the item.

Parameters:
item - ListItem - item to be selected

getSelection

public int getSelection()
get the index of the currently selected entry.

Returns:
int - index of selected entry or -1 for none.

getSelectionText

public java.lang.String getSelectionText()
get the text of the currently selected entry.

Returns:
String - text of selected entry or null.

setExpanded

public void setExpanded(boolean mode)
set the expanded mode of the combobox.

Parameters:
mode - boolean - new expanded mode.

handlePenDown

public ActionEvent handlePenDown(int xc,
                                 int yc)
Handle a "pen down" event. Return an ActionEvent if neccessary.

Overrides:
handlePenDown in class BasicWidget
Parameters:
xc - int - x coordinate of hit point.
yc - int - y coordinate of hit point.
Returns:
ActionEvent - event triggered by PenDown (or null).
See Also:
ActionEvent

handlePenMove

public ActionEvent handlePenMove(int xc,
                                 int yc)
Handle a "pen move" event. Return an ActionEvent if neccessary.

Overrides:
handlePenMove in class BasicWidget
Parameters:
xc - int - x coordinate of pen point.
yc - int - y coordinate of pen point.
Returns:
ActionEvent - event triggered by PenMove (or null).
See Also:
ActionEvent

handlePenUp

public ActionEvent handlePenUp(int xc,
                               int yc)
Handle a "pen up" event. Return an ActionEvent if neccessary.

Overrides:
handlePenUp in class BasicWidget
Parameters:
xc - int - x coordinate of pen point.
yc - int - y coordinate of pen point.
Returns:
ActionEvent - event triggered by PenUp (or null).
See Also:
ActionEvent

handleKeyDown

public ActionEvent handleKeyDown(int keyCode)
Handle a "keyDown" event. Return an ActionEvent if neccessary.

Overrides:
handleKeyDown in class BasicWidget
Parameters:
key - int - key send to the control.
Returns:
ActionEvent - event triggered by keyDown (or null).
See Also:
ActionEvent

paint

public void paint()
Paint the user control.

Overrides:
paint in class BasicWidget