brf.j2me.dynaworks.ui
Class BasicWidget

java.lang.Object
  |
  +--brf.j2me.dynaworks.ui.BasicWidget
All Implemented Interfaces:
UserWidget
Direct Known Subclasses:
Button, CheckBox, ComboBox, ListBox, RadioButton, ScrollBar, Slider, TextBox, TextField, Tree

public abstract class BasicWidget
extends java.lang.Object
implements UserWidget

Basic implementation of a UserWidget.

This class can be used (extended) for many custom controls.

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

Field Summary
protected static Graphics g
          static reference to the graphics canvas.
protected  int h
          height (in pixel) of the control.
protected  int w
          width (in pixel) of the control.
protected  int x
          x-coordinate of the upper-left corner.
protected  int y
          y-coordinate of the upper-left corner.
 
Constructor Summary
BasicWidget()
           
 
Method Summary
(package private) static void ()
           
 boolean contains(int xc, int yc)
          check if point is inside the widget
 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.
 ActionEvent handleSysKeyDown(int keyCode)
          Handle a "sysKeyDown" event.
 boolean hasFocus()
          Does the control have the focus?
 void loseFocus()
          control is losing the focus.
abstract  void paint()
          Paint the user control.
 void setFocus()
          set the focus on this control
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

x

protected int x
x-coordinate of the upper-left corner.


y

protected int y
y-coordinate of the upper-left corner.


w

protected int w
width (in pixel) of the control.


h

protected int h
height (in pixel) of the control.


g

protected static Graphics g
static reference to the graphics canvas.

Constructor Detail

BasicWidget

public BasicWidget()
Method Detail

static void ()

contains

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

Specified by:
contains in interface UserWidget
Parameters:
xc - int - x coordinate of check point.
yc - int - y coordinate of check point.
Returns:
boolean - point inside control?

setFocus

public void setFocus()
set the focus on this control

Specified by:
setFocus in interface UserWidget

hasFocus

public boolean hasFocus()
Does the control have the focus?

Specified by:
hasFocus in interface UserWidget
Returns:
boolean - focus on this control?

loseFocus

public void loseFocus()
control is losing the focus.

Specified by:
loseFocus in interface UserWidget

handlePenDown

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

Specified by:
handlePenDown in interface UserWidget
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.

Specified by:
handlePenMove in interface UserWidget
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.

Specified by:
handlePenUp in interface UserWidget
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.

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

handleSysKeyDown

public ActionEvent handleSysKeyDown(int keyCode)
Handle a "sysKeyDown" event. Return an ActionEvent if neccessary.

Specified by:
handleSysKeyDown in interface UserWidget
Parameters:
key - int - key send to the control.
Returns:
ActionEvent - event triggered by keyDown (or null).
See Also:
ActionEvent

paint

public abstract void paint()
Paint the user control.

Specified by:
paint in interface UserWidget