com.sun.kjava
Class RadioButton

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

public class RadioButton
extends java.lang.Object

A two-state button meant as part of a group, only one of which can be "on" at one time.

See Also:
RadioGroup

Constructor Summary
RadioButton()
          Create a new RadioButton.
RadioButton(int x, int y, java.lang.String text)
          Create a new RadioButton.
 
Method Summary
 java.lang.String getText()
          Get the label of the button.
 void handlePenDown(int x, int y)
          The pen has gone down in the button.
 boolean isSelected()
          Is this RadioButton currently selected?
 void paint()
          Paint the RadioButton on the screen.
 boolean pressed(int x, int y)
          Did the user press inside the RadioButton?
 void setLocation(int x, int y)
          Set the position of the RadioButton.
 void setParent(RadioGroup rg)
          Set the parent RadioGroup of this button.
 void setState(boolean state)
          Set the state of the button.
 void setText(java.lang.String text)
          Set the label of the button.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RadioButton

public RadioButton()
Create a new RadioButton.

RadioButton

public RadioButton(int x,
                   int y,
                   java.lang.String text)
Create a new RadioButton.
Parameters:
x - the X coordinate of the RadioButton's position
y - the Y coordinate of the RadioButton's position
text - the label for the button
Method Detail

setLocation

public void setLocation(int x,
                        int y)
Set the position of the RadioButton.
Parameters:
x - the X coordinate of the RadioButton's position
y - the Y coordinate of the RadioButton's position

setText

public void setText(java.lang.String text)
Set the label of the button.
Parameters:
text - the new text of the label

getText

public java.lang.String getText()
Get the label of the button.
Returns:
the text of the label

paint

public void paint()
Paint the RadioButton on the screen.

handlePenDown

public void handlePenDown(int x,
                          int y)
The pen has gone down in the button. Handle making or removing the selection.
Parameters:
x - the X coordinate of the RadioButton's position
y - the Y coordinate of the RadioButton's position

pressed

public boolean pressed(int x,
                       int y)
Did the user press inside the RadioButton?
Parameters:
x - the X coordinate of the RadioButton's position
y - the Y coordinate of the RadioButton's position
Returns:
true if the coordinates are within the area, false otherwise.

setParent

public void setParent(RadioGroup rg)
Set the parent RadioGroup of this button.
Parameters:
rg - the parental RadioGroup

setState

public void setState(boolean state)
Set the state of the button.
Parameters:
state - the new state; true means "selected"

isSelected

public boolean isSelected()
Is this RadioButton currently selected?
Returns:
true if selected, false if not