waba.ui
Class Button

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--waba.ui.Button

public class Button
extends Control

Button is a push button control.

Here is an example showing a push button being used:

 public class MyProgram extends MainWindow
 {
 Button pushB;

 public void onStart()
  {
  pushB = new Button("Push me");
  pushB.setRect(10, 10, 80, 30);
  add(pushB);
  }
 
 public void onEvent(Event event)
  {
  if (event.type == ControlEvent.PRESSED &&
      event.target == pushB)
   {
   ... handle pushB being pressed
 


Fields inherited from class waba.ui.Control
BOTTOM, CENTER, controlCount, enabled, FILL, fm, font, height, LEFT, name, next, parent, PREFERRED, prev, RIGHT, TOP, width, x, y
 
Constructor Summary
Button(java.lang.String text)
          Creates a button displaying the given text.
 
Method Summary
static void drawButton(Graphics g, boolean armed, int width, int height)
           
 int getPreferredHeight()
          returns the preffered height of this control. added by guich
 int getPreferredWidth()
          returns the preffered width of this control. added by guich
 java.lang.String getText()
          Gets the text displayed in the button.
 void onEvent(Event event)
          Called by the system to pass events to the button.
 void onPaint(Graphics g)
          Called by the system to draw the button. it cuts the text if the button is too small.
 void setText(java.lang.String text)
          Sets the text that is displayed in the button.
 java.lang.String toString()
          Returns the string representation of the object.
 
Methods inherited from class waba.ui.Control
addTimer, contains, createGraphics, getAbsoluteRect, getFontMetrics, getNext, getParent, getRect, isEnabled, isVisible, onBoundsChanged, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, setEnabled, setFont, setRect, setRect, setVisible
 
Methods inherited from class java.lang.Object
hashCode
 

Constructor Detail

Button

public Button(java.lang.String text)
Creates a button displaying the given text.
Method Detail

setText

public void setText(java.lang.String text)
Sets the text that is displayed in the button.

getText

public java.lang.String getText()
Gets the text displayed in the button.

getPreferredWidth

public int getPreferredWidth()
returns the preffered width of this control. added by guich
Overrides:
getPreferredWidth in class Control

getPreferredHeight

public int getPreferredHeight()
returns the preffered height of this control. added by guich
Overrides:
getPreferredHeight in class Control

onEvent

public void onEvent(Event event)
Called by the system to pass events to the button.
Overrides:
onEvent in class Control
Tags copied from class: Control
Parameters:
event - the event to process
See Also:
Event, KeyEvent, PenEvent

drawButton

public static void drawButton(Graphics g,
                              boolean armed,
                              int width,
                              int height)

onPaint

public void onPaint(Graphics g)
Called by the system to draw the button. it cuts the text if the button is too small.
Overrides:
onPaint in class Control
Tags copied from class: Control
Parameters:
g - the graphics object for drawing
See Also:
Graphics

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Returns the string representation of the object.
Overrides:
toString in class java.lang.Object