dog.gui
Class DCheckbox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--dog.gui.DComponent
              |
              +--dog.gui.DCheckbox
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, Referential, java.io.Serializable
Direct Known Subclasses:
DButton

public class DCheckbox
extends DComponent

A multiline checkbox component.

The checkbox can be in one of two states: on or off. The behaviour of checkboxes can be controlled by setting its group (a DCheckboxGroup manager). This handles the dependencies between a set of checkboxes and buttons. When a checkbox has a group, its indicator is drawn as a circle. Otherwise it is drawn as a square. User activity generates item events (a state change of 1 indicates that the checkbox is on, and 0 indicates that it is off).

You can specify a label and alignment for the button. The graphic indicator is displayed on the edge defined by the alignment, and the label is aligned against the inner edge of the indicator.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  int align
          The checkbox alignment.
protected  java.lang.String command
          The command to send in action events.
protected  boolean down
          Whether the checkbox is currently being pressed.
protected  boolean focus
           
protected  DCheckboxGroup group
          The checkbox group that controls this checkbox.
protected  java.lang.String label
          The checkbox label.
static int LEFT
          The left alignment.
static int RIGHT
          The right alignment.
protected  boolean value
          The value of the checkbox.
 
Fields inherited from class dog.gui.DComponent
CENTER, CENTER_TILE, changes, EAST, INTEGER_TILE, MAXIMIZE, MAXIMIZE_ASPECT, MAXIMIZE_HORIZONTAL, MAXIMIZE_VERTICAL, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, TILE, tooltip, WEST
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DCheckbox()
          Constructs a checkbox with no label.
DCheckbox(boolean value)
          Constructs a checkbox with no label and the specified value.
DCheckbox(java.lang.String label)
          Constructs a checkbox with the specified label.
DCheckbox(java.lang.String label, boolean value)
          Constructs a checkbox with the specified label and value.
DCheckbox(java.lang.String label, boolean value, DCheckboxGroup group)
          Constructs a checkbox with the specified label, value, and group.
DCheckbox(java.lang.String label, DCheckboxGroup group)
          Constructs a checkbox with the specified label and group.
DCheckbox(java.lang.String label, int align)
          Constructs a checkbox with the specified label and alignment.
DCheckbox(java.lang.String label, int align, boolean value)
          Constructs a checkbox with the specified label, alignment, and value.
DCheckbox(java.lang.String label, int align, boolean value, DCheckboxGroup group)
          Constructs a checkbox with the specified label, alignament, value, and group.
DCheckbox(java.lang.String label, int align, DCheckboxGroup group)
          Constructs a checkbox with the specified label, alignment, and group.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified action listener to receive action events from this component.
 java.lang.String getActionCommand()
          Returns this checkbox' action command.
 int getAlign()
          Returns the alignment of the checkbox (LEFT or RIGHT).
 DCheckboxGroup getGroup()
          Returns the group managing interdependencies between this checkbox and others.
 java.lang.String getLabel()
          Returns the label.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size for this checkbox.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of this checkbox.
 java.lang.String getText()
          This is an alias for getLabel().
 boolean getValue()
          Indicates whether the checkbox is on or off.
 boolean isFocusTraversable()
          This component is focus-traversable if it is not disabled.
 void paint(java.awt.Graphics g)
          Paints this checkbox.
protected  java.lang.String paramString()
          Returns the parameter string for this component.
protected  void processActionEvent(java.awt.event.ActionEvent event)
          Processes action events on this checkbox by dispatching them to any registered ActionListeners.
protected  void processEvent(java.awt.AWTEvent event)
          Processes events on this checkbox.
protected  void processFocusEvent(java.awt.event.FocusEvent event)
          Processes focus events on this checkbox by dispatching them to any registered FocusListener objects.
protected  void processKeyEvent(java.awt.event.KeyEvent event)
          Processes mouse events on this checkbox by dispatching them to any registered MouseListener objects.
protected  void processMouseEvent(java.awt.event.MouseEvent event)
          Processes mouse events on this checkbox by dispatching them to any registered MouseListener objects.
protected  void processMouseMotionEvent(java.awt.event.MouseEvent event)
          Processes mouse motion events on this checkbox by dispatching them to any registered MouseMotionListener objects.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes the specified action listener so it no longer receives action events from this component.
 void setActionCommand(java.lang.String command)
          Sets the action command.
 void setAlign(int align)
          Sets the checkbox alignment.
 void setGroup(DCheckboxGroup group)
          Sets the group managing interdependencies between this checkbox and others.
 void setLabel(java.lang.String label)
          Sets the label.
 void setText(java.lang.String text)
          This is an alias for setLabel().
 void setValue(boolean value)
          Sets the checkbox state.
 void update(java.awt.Graphics g)
          Updates this checkbox's graphics context.
 
Methods inherited from class dog.gui.DComponent
addPropertyChangeListener, alignParamString, drawActiveButtonBorder, drawActiveOptionBorder, drawArrow, drawBackgroundImage, drawBorder, drawButtonBorder, drawCheckbox, drawDarkBorder, drawDefaultButtonBorder, drawDisabledBorder, drawDisabledCheckbox, drawDisabledOption, drawExpander, drawFocusBorder, drawImage, drawLabel, drawOption, drawOptionBorder, drawPressedBorder, drawTick, getDefaultToolkit, getImage, getImage, getImage, getReference, getRootPane, getRows, getTooltip, isPreloadImages, parseColor, parseFont, processCancelAction, processDefaultAction, removePropertyChangeListener, setEnabled, setPreloadImages, setReference, setTooltip, toString
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

public static final int LEFT
The left alignment.

RIGHT

public static final int RIGHT
The right alignment.

value

protected boolean value
The value of the checkbox.

down

protected boolean down
Whether the checkbox is currently being pressed.

label

protected java.lang.String label
The checkbox label.

align

protected int align
The checkbox alignment.

group

protected DCheckboxGroup group
The checkbox group that controls this checkbox.

command

protected java.lang.String command
The command to send in action events.

focus

protected transient boolean focus
Constructor Detail

DCheckbox

public DCheckbox()
Constructs a checkbox with no label.

DCheckbox

public DCheckbox(java.lang.String label)
Constructs a checkbox with the specified label.

DCheckbox

public DCheckbox(java.lang.String label,
                 int align)
Constructs a checkbox with the specified label and alignment.

DCheckbox

public DCheckbox(boolean value)
Constructs a checkbox with no label and the specified value.

DCheckbox

public DCheckbox(java.lang.String label,
                 boolean value)
Constructs a checkbox with the specified label and value.

DCheckbox

public DCheckbox(java.lang.String label,
                 int align,
                 boolean value)
Constructs a checkbox with the specified label, alignment, and value.

DCheckbox

public DCheckbox(java.lang.String label,
                 int align,
                 DCheckboxGroup group)
Constructs a checkbox with the specified label, alignment, and group.

DCheckbox

public DCheckbox(java.lang.String label,
                 DCheckboxGroup group)
Constructs a checkbox with the specified label and group.

DCheckbox

public DCheckbox(java.lang.String label,
                 boolean value,
                 DCheckboxGroup group)
Constructs a checkbox with the specified label, value, and group.

DCheckbox

public DCheckbox(java.lang.String label,
                 int align,
                 boolean value,
                 DCheckboxGroup group)
Constructs a checkbox with the specified label, alignament, value, and group.
Method Detail

getValue

public boolean getValue()
Indicates whether the checkbox is on or off.
See Also:
setValue(boolean)

setValue

public void setValue(boolean value)
Sets the checkbox state.
Parameters:
flag - true if on, false if off.
See Also:
getValue()

getText

public java.lang.String getText()
This is an alias for getLabel().
See Also:
getLabel()

setText

public void setText(java.lang.String text)
This is an alias for setLabel().
See Also:
setLabel(java.lang.String)

getLabel

public java.lang.String getLabel()
Returns the label.
See Also:
setLabel(java.lang.String)

setLabel

public void setLabel(java.lang.String label)
Sets the label.
Parameters:
label - the label text.
See Also:
getLabel()

getAlign

public int getAlign()
Returns the alignment of the checkbox (LEFT or RIGHT).
See Also:
setAlign(int)

setAlign

public void setAlign(int align)
Sets the checkbox alignment.
Parameters:
align - LEFT or RIGHT.
See Also:
getAlign()

getGroup

public DCheckboxGroup getGroup()
Returns the group managing interdependencies between this checkbox and others.
See Also:
setGroup(dog.gui.DCheckboxGroup)

setGroup

public void setGroup(DCheckboxGroup group)
Sets the group managing interdependencies between this checkbox and others.
See Also:
getGroup()

getActionCommand

public java.lang.String getActionCommand()
Returns this checkbox' action command. If it has not been set this is the label.
See Also:
setActionCommand(java.lang.String)

setActionCommand

public void setActionCommand(java.lang.String command)
Sets the action command.
See Also:
getActionCommand()

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size for this checkbox. The minimum size is calculated as the length of the longest word (plus the indicator) by the font height.
Overrides:
getMinimumSize in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of this checkbox. The minimum size is calculated as the length of the longest line (plus the indicator) by the font height times the number of lines.
Overrides:
getPreferredSize in class java.awt.Component

update

public void update(java.awt.Graphics g)
Updates this checkbox's graphics context.
Overrides:
update in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Paints this checkbox.
Overrides:
paint in class java.awt.Component
Parameters:
ds - the control dark shadow colour to use
h - the control highlight colour to use
c - the control colour to use
pc - the primary control colour to use
pcds - the primary control dark shadow colour to use
f - the colour to draw the dot in

isFocusTraversable

public boolean isFocusTraversable()
This component is focus-traversable if it is not disabled.
Overrides:
isFocusTraversable in class java.awt.Component

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this component.
Parameters:
listener - the action listener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes the specified action listener so it no longer receives action events from this component.
Parameters:
listener - the action listener

processEvent

protected void processEvent(java.awt.AWTEvent event)
Processes events on this checkbox. If the event is an ActionEvent, it invokes the processItemEvent method. Otherwise it invokes the superclass processEvent.
Overrides:
processEvent in class DComponent
Parameters:
event - the event

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent event)
Processes action events on this checkbox by dispatching them to any registered ActionListeners.
Parameters:
event - the action event

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent event)
Processes focus events on this checkbox by dispatching them to any registered FocusListener objects.
Overrides:
processFocusEvent in class java.awt.Component
Parameters:
event - the focus event

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent event)
Processes mouse events on this checkbox by dispatching them to any registered MouseListener objects.
Overrides:
processKeyEvent in class java.awt.Component
Parameters:
event - the mouse event

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent event)
Processes mouse events on this checkbox by dispatching them to any registered MouseListener objects.
Overrides:
processMouseEvent in class DComponent
Parameters:
event - the mouse event

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent event)
Processes mouse motion events on this checkbox by dispatching them to any registered MouseMotionListener objects.
Overrides:
processMouseMotionEvent in class DComponent
Parameters:
event - the mouse motion event

paramString

protected java.lang.String paramString()
Returns the parameter string for this component.
Overrides:
paramString in class DComponent