com.sun.kjava
Class Button

java.lang.Object
  |
  +--com.sun.kjava.Button

public class Button
extends java.lang.Object

Button: a simple button user interface object. Note that this button causes actions to occur when it it pressed, not when it is released. Therefore it is currently impossible for a user to cancel a button selection once it has started! Bitmap buttons do not have a border drawn around them. If you want your bitmap button to have a border, include the border in the bitmap.


Field Summary
static int minWidth
           
 
Constructor Summary
Button(Bitmap bitmap, int x, int y)
          Create a new Button object with graphical label.
Button(java.lang.String s, int x, int y)
          Create a new Button object with a text label.
 
Method Summary
 boolean isEnabled()
          Is the Button enabled?
 void paint()
          Paint the Button on the global Graphics context.
 boolean pressed(int x, int y)
          Was the button pressed? If the coordinates are within the Button, give the user some feedback.
 void setEnabled(boolean state)
          Set whether the Button allows input (is "enabled").
 void setText(java.lang.String s)
          Set the Button's text label.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minWidth

public static final int minWidth
Constructor Detail

Button

public Button(java.lang.String s,
              int x,
              int y)
Create a new Button object with a text label.
Parameters:
s - the button's text label
x - the x coordinate of the button's location
y - the y coordinate of the button's location

Button

public Button(Bitmap bitmap,
              int x,
              int y)
Create a new Button object with graphical label.
Parameters:
s - the button's text label
x - the x coordinate of the button's location
y - the y coordinate of the button's location
Method Detail

setText

public void setText(java.lang.String s)
Set the Button's text label.
Parameters:
s - the new label for the button.

setEnabled

public void setEnabled(boolean state)
Set whether the Button allows input (is "enabled").
Parameters:
state - if true, Button allows input.

isEnabled

public boolean isEnabled()
Is the Button enabled?
Returns:
true if the Button accepts input, false if not.

paint

public void paint()
Paint the Button on the global Graphics context. If the Button is not enabled, it draws in a "grayed out" style.

pressed

public boolean pressed(int x,
                       int y)
Was the button pressed? If the coordinates are within the Button, give the user some feedback.
Returns:
true if the coordinates were within the bounds of the Button.