lcarsbeans
Class LcarsCheckbox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--lcarsbeans.LcarsCheckbox

public class LcarsCheckbox
extends java.awt.Canvas
implements java.io.Serializable, java.awt.event.MouseListener

A checkbox, in combination with LcarsCheckboxGroup also usable as radiobutton.

Version:
0.9b, January 2002 (March 2001)
Author:
Andrei Scheibner, www.buffalo-as.de, andrei@buffalo-as.de
See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
static int cbsOne
          First style: Depending on the state property the color changes between checkedColor and uncheckedColor.
static int cbsTwo
          Second style: The control is drawn using checkedColor, but when state is false the small part of the control is not drawn.
protected  LcarsCheckboxGroup group
          The LcarsCheckboxGroup which is associated with the checkbox.
static int haLeftJustify
          The part of the control with the label on it is at the left side.
static int haRightJustify
          The part of the control with the label on it is at the right side.
static int lpBottomLeft
          Label is shown in the lower left corner of the control.
static int lpBottomRight
          Label is shown in the lower right corner of the control.
static int lpCenter
          Label is shown horizontally and vertically centered.
static int lpTopLeft
          Label is shown in the upper left corner of the control.
static int lpTopRight
          Label is shown in the upper right corner of the control.
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
LcarsCheckbox()
          Constructs a new instance.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds an Action Listener.
protected  void fireAction()
          Sends the Action-Event to all listeners.
 LcarsCheckboxGroup getCheckboxGroup()
          Returns the LcarsCheckbox which is associated with this checkbox.
 java.awt.Color getCheckedColor()
          Returns the color which is used when the state property is true.
 java.awt.Color getDisabledColor()
          Returns the color which is used when the control is not enabled.
 java.awt.Color getFontColor()
          Returns the color used for drawing the label.
 int getHorizontalAlignment()
          Returns the horizontal aligment of the control.
 int getHorizontalSpace()
          Returns the horizontal space between the part with the label and the small part of the control.
 java.lang.String getLabel()
          Returns the label.
 int getLabelMarginX()
          Returns the horizontal margin between the label and the bound of the control.
 int getLabelMarginY()
          Returns the vertical margin between the label and the bound of the control.
 int getLabelPosition()
          Returns the position of the label.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the component.
 int getStyle()
          Returns the style of the control.
 java.awt.Color getUncheckedColor()
          Returns the color which is used when the state property is false.
 boolean isRoundLong()
          Returns whether the part with the caption is drawn rounded.
 boolean isRoundShort()
          Returns whether the small part is drawn rounded.
 boolean isState()
          Returns the state of the control (true = checked, false = unchecked).
 void mouseClicked(java.awt.event.MouseEvent evt)
          Event handler (not implemented)
 void mouseEntered(java.awt.event.MouseEvent evt)
          Event handler (not implemented)
 void mouseExited(java.awt.event.MouseEvent evt)
          Event handler (not implemented)
 void mousePressed(java.awt.event.MouseEvent evt)
          Event handler (not implemented)
 void mouseReleased(java.awt.event.MouseEvent evt)
          Event handler
 void paint(java.awt.Graphics g)
          Paints the control.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes an Action Listener.
 void setCheckboxGroup(LcarsCheckboxGroup newGroup)
          Associates the checkbox with a LcarsCheckboxGroup.
If 2 or more checkboxes are associated with a certain LcarsCheckboxGroup they work as radiobuttons.
 void setCheckedColor(java.awt.Color newCheckedColor)
          Sets the color which is used when the state property is true.
 void setDisabledColor(java.awt.Color newDisabledColor)
          Sets the color which is used when the control is not enabled.
 void setFontColor(java.awt.Color newFontColor)
          Sets the color used for drawing the label.
 void setHorizontalAlignment(int newHorizontalAlignment)
          Sets the horizontal aligment of the control, that means whether the part with the label is at the left or right side.
Possible values: haLeftJustify, haRightJustify
If the new value is not 0 or 1 the property is set to haLeftJustify.
 void setHorizontalSpace(int newHorizontalSpace)
          Sets the horizontal space between the part with the label and the small part of the control.
 void setLabel(java.lang.String newLabel)
          Sets the label.
 void setLabelMarginX(int newLabelMarginX)
          Sets the horizontal margin between the label and the bound of the control if the label position is not lpCenter.
 void setLabelMarginY(int newLabelMarginY)
          Sets the vertical margin between the label and the bound of the control if the label position is not lpCenter.
 void setLabelPosition(int newLabelPosition)
          Sets the position of the label.
Possible values: lpCenter, lpTopLeft, lpTopRight, lpBottomRight, lpBottomLeft
If the new value is not in the range between 0 and 4 the property is set to lpCenter.
 void setRoundLong(boolean newRoundLong)
          Sets whether the part with the caption is drawn rounded.
 void setRoundShort(boolean newRoundShort)
          Sets whether the small part is drawn rounded.
 void setState(boolean newState)
          Sets the state of the control (true = checked, false = unchecked).
 void setStyle(int newStyle)
          Sets the style of the control.
Possible values: cbsOne, cbsTwo
If the new value is not 0 or 1 the property is set to cbsOne.
 void setUncheckedColor(java.awt.Color newUncheckedColor)
          Sets the color which is used when the state property is false.
 void Toggle()
          Toggles the state property between true and false.
 void update(java.awt.Graphics g)
          An overwritten and because of this almost flicker-free version of update().
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lpCenter

public static final int lpCenter
Label is shown horizontally and vertically centered.

lpTopLeft

public static final int lpTopLeft
Label is shown in the upper left corner of the control.

lpTopRight

public static final int lpTopRight
Label is shown in the upper right corner of the control.

lpBottomRight

public static final int lpBottomRight
Label is shown in the lower right corner of the control.

lpBottomLeft

public static final int lpBottomLeft
Label is shown in the lower left corner of the control.

haLeftJustify

public static final int haLeftJustify
The part of the control with the label on it is at the left side.

haRightJustify

public static final int haRightJustify
The part of the control with the label on it is at the right side.

cbsOne

public static final int cbsOne
First style: Depending on the state property the color changes between checkedColor and uncheckedColor.

cbsTwo

public static final int cbsTwo
Second style: The control is drawn using checkedColor, but when state is false the small part of the control is not drawn.

group

protected LcarsCheckboxGroup group
The LcarsCheckboxGroup which is associated with the checkbox.
Constructor Detail

LcarsCheckbox

public LcarsCheckbox()
Constructs a new instance.
Method Detail

paint

public void paint(java.awt.Graphics g)
Paints the control.
Overrides:
paint in class java.awt.Canvas

update

public void update(java.awt.Graphics g)
An overwritten and because of this almost flicker-free version of update().
Overrides:
update in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the component.
Overrides:
getPreferredSize in class java.awt.Component

isState

public boolean isState()
Returns the state of the control (true = checked, false = unchecked).

setState

public void setState(boolean newState)
Sets the state of the control (true = checked, false = unchecked).

Toggle

public void Toggle()
Toggles the state property between true and false.

getStyle

public int getStyle()
Returns the style of the control.

setStyle

public void setStyle(int newStyle)
Sets the style of the control.
Possible values: cbsOne, cbsTwo
If the new value is not 0 or 1 the property is set to cbsOne.

getFontColor

public java.awt.Color getFontColor()
Returns the color used for drawing the label.

setFontColor

public void setFontColor(java.awt.Color newFontColor)
Sets the color used for drawing the label.

getLabel

public java.lang.String getLabel()
Returns the label.

setLabel

public void setLabel(java.lang.String newLabel)
Sets the label.

getLabelPosition

public int getLabelPosition()
Returns the position of the label.

setLabelPosition

public void setLabelPosition(int newLabelPosition)
Sets the position of the label.
Possible values: lpCenter, lpTopLeft, lpTopRight, lpBottomRight, lpBottomLeft
If the new value is not in the range between 0 and 4 the property is set to lpCenter.

getLabelMarginX

public int getLabelMarginX()
Returns the horizontal margin between the label and the bound of the control.

setLabelMarginX

public void setLabelMarginX(int newLabelMarginX)
Sets the horizontal margin between the label and the bound of the control if the label position is not lpCenter.

getLabelMarginY

public int getLabelMarginY()
Returns the vertical margin between the label and the bound of the control.

setLabelMarginY

public void setLabelMarginY(int newLabelMarginY)
Sets the vertical margin between the label and the bound of the control if the label position is not lpCenter.

getHorizontalSpace

public int getHorizontalSpace()
Returns the horizontal space between the part with the label and the small part of the control.

setHorizontalSpace

public void setHorizontalSpace(int newHorizontalSpace)
Sets the horizontal space between the part with the label and the small part of the control.

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal aligment of the control.

setHorizontalAlignment

public void setHorizontalAlignment(int newHorizontalAlignment)
Sets the horizontal aligment of the control, that means whether the part with the label is at the left or right side.
Possible values: haLeftJustify, haRightJustify
If the new value is not 0 or 1 the property is set to haLeftJustify.

isRoundLong

public boolean isRoundLong()
Returns whether the part with the caption is drawn rounded.

setRoundLong

public void setRoundLong(boolean newRoundLong)
Sets whether the part with the caption is drawn rounded.

isRoundShort

public boolean isRoundShort()
Returns whether the small part is drawn rounded.

setRoundShort

public void setRoundShort(boolean newRoundShort)
Sets whether the small part is drawn rounded.

getCheckedColor

public java.awt.Color getCheckedColor()
Returns the color which is used when the state property is true.

setCheckedColor

public void setCheckedColor(java.awt.Color newCheckedColor)
Sets the color which is used when the state property is true.

getUncheckedColor

public java.awt.Color getUncheckedColor()
Returns the color which is used when the state property is false.

setUncheckedColor

public void setUncheckedColor(java.awt.Color newUncheckedColor)
Sets the color which is used when the state property is false.

getDisabledColor

public java.awt.Color getDisabledColor()
Returns the color which is used when the control is not enabled.

setDisabledColor

public void setDisabledColor(java.awt.Color newDisabledColor)
Sets the color which is used when the control is not enabled.

getCheckboxGroup

public LcarsCheckboxGroup getCheckboxGroup()
Returns the LcarsCheckbox which is associated with this checkbox.

setCheckboxGroup

public void setCheckboxGroup(LcarsCheckboxGroup newGroup)
Associates the checkbox with a LcarsCheckboxGroup.
If 2 or more checkboxes are associated with a certain LcarsCheckboxGroup they work as radiobuttons.

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Event handler (not implemented)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Event handler (not implemented)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Event handler
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Event handler (not implemented)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Event handler (not implemented)
Specified by:
mouseExited in interface java.awt.event.MouseListener

fireAction

protected void fireAction()
Sends the Action-Event to all listeners.

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds an Action Listener.

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes an Action Listener.