kAWT Version 0.98

java.awt
Class Checkbox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Checkbox

public class Checkbox
extends Component
implements ItemSelectable

The Checkbox class can be used to display checkbox or radio button components. Checkboxes can be checked or unchecked. Radio buttons are created by assigning a group to checkboxes. Only one of the radio buttons of a group can be checked at a time, similar to the channel buttons of a radio. If a radio button is selected, the other radio buttons of the same group are unchecked automatically.


Constructor Summary
Checkbox()
          Constructs a checkbox without a label
Checkbox(String s)
          Construct a checkbox with the given label
Checkbox(String label, boolean checked)
          Constructs a checkbox with the given label and state
Checkbox(String s, boolean state, CheckboxGroup group)
          Constructs a radio button with the given label and state belonging to the given checkbox group.
Checkbox(String s, CheckboxGroup group, boolean state)
          Constructs a radio button with the given label and state belonging to the given checkbox group.
 
Method Summary
 void addItemListener(ItemListener il)
          Adds an item listener to this checkbox.
 Object[] getSelectedObjects()
          returns the an object array containing this checkbox if it is selected, otherwise an empty object array.
 boolean getState()
          Returns the selection state of the checkbox.
 void paint(Graphics g)
          Paints the checkbox to the given graphics context.
 void processItemEvent(ItemEvent e)
          Processed the given item event by calling the registered listener.
 void removeItemListener(ItemListener l)
          Removes the giveb item listener if it is registerd for this component
 void setCheckboxGroup(CheckboxGroup newGroup)
          Assigns a checkbox group to this checkbox and turns it into a radio button.
 void setLabel(String s)
          Sets the label of the checkbox.
 void setState(boolean sel)
          Sets the selection state of this checkbox and repaints it (deferred) if neccessary.
 
Methods inherited from class java.awt.Component
addKeyListener, addMouseListener, addMouseMotionListener, contains, findComponentAt, getBackground, getBounds, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getLocationOnScreen, getMaximumSize, getMinimumSize, getParent, getPreferredSize, getSize, getWidth, getX, getY, hasFocus, invalidate, isEnabled, isFocusTraversable, isValid, isVisible, paintAll, processKeyEvent, processMouseEvent, repaint, repaint, requestFocus, setBackground, setBounds, setEnabled, setForeground, setLocation, setSize, setSize, setVisible, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Checkbox

public Checkbox()
Constructs a checkbox without a label

Checkbox

public Checkbox(String s)
Construct a checkbox with the given label

Checkbox

public Checkbox(String label,
                boolean checked)
Constructs a checkbox with the given label and state

Checkbox

public Checkbox(String s,
                boolean state,
                CheckboxGroup group)
Constructs a radio button with the given label and state belonging to the given checkbox group.

Checkbox

public Checkbox(String s,
                CheckboxGroup group,
                boolean state)
Constructs a radio button with the given label and state belonging to the given checkbox group.
Method Detail

addItemListener

public void addItemListener(ItemListener il)
Adds an item listener to this checkbox. The item listener is notified when the checkbox is selected or unselected. Attention: kAWT supports only one item listener for each checkbox.
Specified by:
addItemListener in interface ItemSelectable

getSelectedObjects

public Object[] getSelectedObjects()
returns the an object array containing this checkbox if it is selected, otherwise an empty object array.
Specified by:
getSelectedObjects in interface ItemSelectable

getState

public boolean getState()
Returns the selection state of the checkbox.

paint

public void paint(Graphics g)
Paints the checkbox to the given graphics context.
Overrides:
paint in class Component

processItemEvent

public void processItemEvent(ItemEvent e)
Processed the given item event by calling the registered listener.

removeItemListener

public void removeItemListener(ItemListener l)
Removes the giveb item listener if it is registerd for this component
Specified by:
removeItemListener in interface ItemSelectable

setCheckboxGroup

public void setCheckboxGroup(CheckboxGroup newGroup)
Assigns a checkbox group to this checkbox and turns it into a radio button. Only one group can be assigned to a checkbox. If the checkbox is already assigned to a group, the previous assignment is removed. A group assignment can be removed by passing null to this method.

setState

public void setState(boolean sel)
Sets the selection state of this checkbox and repaints it (deferred) if neccessary.

setLabel

public void setLabel(String s)
Sets the label of the checkbox.

kAWT Version 0.98