Ascent Phase Corp.

org.ascentphase.suit
Class PushButton

java.lang.Object
  |
  +--org.ascentphase.suit.Widget
        |
        +--org.ascentphase.suit.PushButton
All Implemented Interfaces:
MutexOption

public class PushButton
extends Widget
implements MutexOption

A PushButton is a button that behaves like a MutexOption.

Version:
Author:
huyd

Field Summary
protected  boolean active
           
protected  int btnHeight
           
protected  int btnWidth
           
protected  org.ascentphase.suit.MutexOptionGroup group
           
protected  java.lang.String label
           
 
Fields inherited from class org.ascentphase.suit.Widget
cmdToThrow
 
Constructor Summary
PushButton(java.lang.String text, int width, int height, org.ascentphase.suit.MutexOptionGroup mog)
          Initialize a PushButton with the given text and belongs to the given MutexOptionGroup.
PushButton(java.lang.String text, org.ascentphase.suit.MutexOptionGroup mog)
          Initialize a PushButton with the given text and belongs to the given MutexOptionGroup.
 
Method Summary
 boolean contains(int x, int y)
          Returns whether the given coordinate lies within this widget's area of interest.
 boolean getActive()
          Returns the state of this MutexOption.
 void paint(Graphics g)
          Draws the widget.
 Command pointerReleased(int x, int y)
          Method called by the widget's containing Panel when a pointer is released over the widget area.
 void setActive(boolean state)
          Notifies whether the MutexOption is currently active or not in its group.
 
Methods inherited from class org.ascentphase.suit.Widget
getCommand, keyPressed, keyReleased, pointerDragged, pointerPressed, setCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

label

protected java.lang.String label

btnWidth

protected int btnWidth

btnHeight

protected int btnHeight

active

protected boolean active

group

protected org.ascentphase.suit.MutexOptionGroup group
Constructor Detail

PushButton

public PushButton(java.lang.String text,
                  org.ascentphase.suit.MutexOptionGroup mog)
Initialize a PushButton with the given text and belongs to the given MutexOptionGroup. The default height and width of the button is determined by the text size.

Parameters:
text - the text to display on the PushButton.
mog - the MutexOptionGroup the PushButton belongs to.

PushButton

public PushButton(java.lang.String text,
                  int width,
                  int height,
                  org.ascentphase.suit.MutexOptionGroup mog)
Initialize a PushButton with the given text and belongs to the given MutexOptionGroup. The height and width of the button is specified, but if the button's text is larger than its width, the text will "leak" outside the drawn borders of the PushButton.

Parameters:
text - the text to display on the PushButton.
width - the width in pixels.
height - the height in pixels.
mog - the MutexOptionGroup the PushButton belongs to.
Method Detail

paint

public void paint(Graphics g)
Draws the widget.

Specified by:
paint in class Widget
Parameters:
g - the Graphics object to draw with.

contains

public boolean contains(int x,
                        int y)
Description copied from class: Widget
Returns whether the given coordinate lies within this widget's area of interest. The coordinate is relative to this widget's coordinate system. This method should return true if the coordinate given is of interest to the widget and the widget wishes to receive the keyXXX events and the pointerXXX events.

Overrides:
contains in class Widget
Parameters:
x - the x coordinate.
y - the y coordinate.

pointerReleased

public Command pointerReleased(int x,
                               int y)
Description copied from class: Widget
Method called by the widget's containing Panel when a pointer is released over the widget area. By default, if this method is not over-ridden, it returns null to indicate no Command event.

Overrides:
pointerReleased in class Widget
Parameters:
x - the x-coordinate relative to the widget's origin.
y - the y-coordinate relative to the widget's origin.
Returns:
a Command event to notify any listeners, or null if none.

setActive

public void setActive(boolean state)
Description copied from interface: MutexOption
Notifies whether the MutexOption is currently active or not in its group.

Specified by:
setActive in interface MutexOption
Parameters:
state - the active state of the MutexOption.

getActive

public boolean getActive()
Description copied from interface: MutexOption
Returns the state of this MutexOption.

Specified by:
getActive in interface MutexOption
Returns:
the current state of the option.

Ascent Phase Corp.

Copyright © 2002 Ascent Phase Corp. All Rights Reserved.