extra.ui
Class Pushbutton

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--extra.ui.Pushbutton
All Implemented Interfaces:
PreferredSize

public class Pushbutton
extends Control
implements PreferredSize

This is a standard palm pushbutton.


Constructor Summary
Pushbutton(String name)
          Constructs a new unconnected, unselected push button.
Pushbutton(String name, boolean state)
          Construct a new unconnected push button with the given selection status.
Pushbutton(String name, boolean state, Pushbutton connection)
          Construct a new push button with the given selection status in the same group as the given pushbutton.
Pushbutton(String name, Pushbutton connection)
          Constructs a new unselected push button in the same group as the given pushbutton.
 
Method Summary
 void connect(Pushbutton pb)
          Connects this Pushbutton with a group.
static Pushbutton[] createGroup(String[] names, int selected)
           
 void disconnect()
          Removes this pushbutton from it's current group.
 int getPreferredHeight(FontMetrics fm)
           
 int getPreferredWidth(FontMetrics fm)
           
 Pushbutton getSelected()
          Gets the pushbutton that is selected in the current group
 String getText()
          Returns the text of this Button
 boolean isSelected()
          Is this pushbutton selected?
 void onEvent(Event event)
          Process pen and key events to this component
 void onPaint(Graphics g)
          Paints the push button to the screen
 void setSelected(boolean b)
          Sets whether the push button is pressed down or not
 
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

Pushbutton

public Pushbutton(String name)
Constructs a new unconnected, unselected push button.
Parameters:
name - the text to go on the button

Pushbutton

public Pushbutton(String name,
                  Pushbutton connection)
Constructs a new unselected push button in the same group as the given pushbutton.
Parameters:
name - the text to go on the button
connection - the pushbutton to connect to

Pushbutton

public Pushbutton(String name,
                  boolean state)
Construct a new unconnected push button with the given selection status.
Parameters:
name - the text to go on the button
state - the state of the button

Pushbutton

public Pushbutton(String name,
                  boolean state,
                  Pushbutton connection)
Construct a new push button with the given selection status in the same group as the given pushbutton.
Parameters:
name - the text to go on the button
state - the state of the button
connection - the pushbutton to connect to
Method Detail

createGroup

public static Pushbutton[] createGroup(String[] names,
                                       int selected)

connect

public void connect(Pushbutton pb)
Connects this Pushbutton with a group. Only one pushbutton in a group can be selected at one time.
Parameters:
pb - the group to connect to

disconnect

public void disconnect()
Removes this pushbutton from it's current group.

getSelected

public Pushbutton getSelected()
Gets the pushbutton that is selected in the current group
Returns:
the selected pushbutton, or null if none

isSelected

public boolean isSelected()
Is this pushbutton selected?
Returns:
true if it is, false otherwise

setSelected

public void setSelected(boolean b)
Sets whether the push button is pressed down or not
Parameters:
b - true if selected, false otherwise

getText

public String getText()
Returns the text of this Button

getPreferredWidth

public int getPreferredWidth(FontMetrics fm)
Specified by:
getPreferredWidth in interface PreferredSize

getPreferredHeight

public int getPreferredHeight(FontMetrics fm)
Specified by:
getPreferredHeight in interface PreferredSize

onPaint

public void onPaint(Graphics g)
Paints the push button to the screen
Overrides:
onPaint in class Control
Following copied from class: waba.ui.Control
Parameters:
g - the graphics object for drawing
See Also:
Graphics

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