com.sas.awt
Class CheckBox

com.sas.awt.CheckBox
All Implemented Interfaces:
VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.lang.StringDataInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, com.sas.PublicClonable, com.sas.ViewDefaultModelInterface, com.sas.ViewInterface, MultipleValueEventSourceInterface, ResizeToFitInterface, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.accessibility.Accessible

public class CheckBox
implements com.sas.lang.StringDataInterface, com.sas.PublicClonable, ResizeToFitInterface, com.sas.ViewDefaultModelInterface

CheckBox is a component that maintains a boolean state and displays a specified text label. A checkbox may optionally be part of a CheckBoxGroup which enforces mutual exclusion (only one item in the group can be selected at any given time).

Creation:

  1. Create a Checkbox with no specified label

    CheckBox checkBox1 = new CheckBox();
    checkBox1.initialize();

  2. Create a Checkbox with the specified text

    CheckBox checkBox1 = new CheckBox("My Text");
    checkBox1.initialize();

    where "My Text" is the text that will appear on the checkbox

  3. Create a Checkbox with the specified text and state

    CheckBox checkBox1 = new CheckBox("My Text", selected);
    checkBox1.initialize();

    where:
  4. Create a Checkbox with the specified text, state, and checkBoxGroup

    CheckBox checkBox1 = new CheckBox("My Text", selected, checkBoxGroup);
    checkBox1.initialize();

    where:

Default Size:
Required Interfaces:
CheckBox requires a model that implements the com.sas.lang.BooleanData interface. A default model is automatically created and attached to the checkbox when the checkbox is initially constructed.

Events:
CheckBox sends out an ItemEvent when it is selected or deselected.

Notes:

See Also:
Serialized Form

Field Summary
static java.lang.String RB_KEY
           
 
Constructor Summary
CheckBox()
          Default constructor
CheckBox(java.util.ResourceBundle bundle, java.lang.String textID)
          Create a CheckBox with the specified text obtained from a resource bundle
CheckBox(java.lang.String text)
          Create a CheckBox with the specified text
CheckBox(java.lang.String text, boolean state)
          Create a CheckBox with the specified text and boolean state
CheckBox(java.lang.String text, boolean state, java.awt.CheckboxGroup group)
          Create a CheckBox with the specified text, boolean state, and Checkbox group
 
Method Summary
 void addNotify()
          Notify the component that it has been added to a container and that the peer should be created.
 void attachModel(com.sas.ModelInterface model)
          Attaches a model to the component.
 java.lang.Object clone()
          Clones the component
 java.awt.Dimension computePreferredSize()
          Returns the preferred size of the component
 void detachModel(com.sas.ModelInterface model)
          Detaches the current model and attaches the default model if the model is set to null
static int getDefaultHeight()
          Returns the default height for instances of this class
static int getDefaultWidth()
          Returns the default width for instances of this class
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns the ExtendedBeanInfo for this class.
 java.util.Vector getRequiredInterfaces()
          Returns the required interfaces Vector for this component.
 java.lang.String getText()
          Returns the CheckBox text.
 boolean isDefaultModelAttached()
          Returns whether the default model is attached.
 boolean isResizeToFit()
          Returns the value of the resizeToFit property The resizeToFit property determines whether to change the size of the component when either the text or font changes.
 boolean isSelected()
          Returns the current state of the checkBox.
protected  void processItemEvent(java.awt.event.ItemEvent e)
          Processes item events occurring on this component.Subclasses should always call super so that events are delivered to any ItemListeners.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Processes a PropertyChangeEvent sent by the model.
 void refresh()
          Sets value of selected property from the value obtained from the attached model
 void refresh(com.sas.ModelInterface model)
          Sets value of selected property from the value obtained from the attached model
 void setCheckboxGroup(java.awt.CheckboxGroup g)
          Sets the CheckboxGroup.
static void setDefaultHeight(int newDefaultHeight)
          Sets the default height of the component.
 void setDefaultValues()
          Sets the initial values to the default values.
static void setDefaultWidth(int newDefaultWidth)
          Sets the default width of the component.
 void setFont(java.awt.Font font)
          Sets the font to be used by the component for displaying text.
 void setLabel(java.lang.String text)
          Sets the CheckBox with the specified text
 void setResizeToFit(boolean resizeToFit)
          Sets the value of the resizeToFit property.
 void setSelected(boolean state)
          Sets the CheckBox to the specified boolean state.
 void setState(boolean state)
          Sets the CheckBox to the specified boolean state
 void setText(java.lang.String text)
          Sets the CheckBox with the specified text.
 
Methods inherited from class com.sas.awt.CheckBoxVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachView, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getMinimumSize, getModelInterface, getPreferredSize, getPrePainter, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, initialize, initializeComponent, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, paint, queryLinks, queryLinks, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setBounds, setComponentDescription, setComponentSupportInfo, setEnabled, setFocus, setForegroundColor, setHeight, setHorizontalPosition, setLinkInfo, setModelInterface, setPreferredSize, setPrePainter, setRequiredInterfaces, setTransparent, setVerticalPosition, setViewInterfaceSupportInfo, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, update, validateObject
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

CheckBox

public CheckBox()
Default constructor


CheckBox

public CheckBox(java.lang.String text)
Create a CheckBox with the specified text

Parameters:
text - text that will appear on the checkbox

CheckBox

public CheckBox(java.util.ResourceBundle bundle,
                java.lang.String textID)
Create a CheckBox with the specified text obtained from a resource bundle

Parameters:
bundle - resource bundle
textID - text identifier in the resource bundle

CheckBox

public CheckBox(java.lang.String text,
                boolean state)
Create a CheckBox with the specified text and boolean state

Parameters:
text - text that will appear on the checkbox
state - boolean that indicates whether the checkBox is checked or unchecked

CheckBox

public CheckBox(java.lang.String text,
                boolean state,
                java.awt.CheckboxGroup group)
Create a CheckBox with the specified text, boolean state, and Checkbox group

Parameters:
text - text that will appear on the checkbox
state - boolean that indicates whether the checkBox is checked or unchecked
group - an instance of java.awt.CheckBoxGroup that the checkBox belongs to
Method Detail

getDefaultWidth

public static int getDefaultWidth()
Returns the default width for instances of this class

Returns:
the default width in pixels
See Also:
setDefaultWidth(int)

setDefaultWidth

public static void setDefaultWidth(int newDefaultWidth)
Sets the default width of the component. The default width will be used by webAF when creating this component.

Parameters:
newDefaultWidth - the new default width in pixels
See Also:
getDefaultWidth()

getDefaultHeight

public static int getDefaultHeight()
Returns the default height for instances of this class

Returns:
the default height in pixels
See Also:
setDefaultHeight(int)

setDefaultHeight

public static void setDefaultHeight(int newDefaultHeight)
Sets the default height of the component. The default height will be used by webAF when creating this component.

Parameters:
newDefaultHeight - the new default height in pixels
See Also:
getDefaultHeight()

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns the ExtendedBeanInfo for this class.

Returns:
ExtendedBeanInfo for this class

addNotify

public void addNotify()
Notify the component that it has been added to a container and that the peer should be created. If resizeToFit is set to true, the component may be resized if the font or label has changed.

Overrides:
addNotify in class java.awt.Checkbox

attachModel

public void attachModel(com.sas.ModelInterface model)
Attaches a model to the component. Listens for PropertyChangeEvents from the model.

Specified by:
attachModel in interface com.sas.ViewInterface
Overrides:
attachModel in class CheckBoxVisualComponent
Parameters:
model - model to attach
See Also:
ViewInterface.attachModel(com.sas.ModelInterface)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones the component

Specified by:
clone in interface com.sas.PublicClonable
Overrides:
clone in class CheckBoxVisualComponent
Returns:
new instance of the CheckBox
Throws:
java.lang.CloneNotSupportedException - if the model attached to the component being cloned will not allow the clone to attach.

computePreferredSize

public java.awt.Dimension computePreferredSize()
Returns the preferred size of the component

Specified by:
computePreferredSize in interface VisualInterface
Overrides:
computePreferredSize in class CheckBoxVisualComponent
Returns:
preferred size
See Also:
VisualInterface.computePreferredSize()

detachModel

public void detachModel(com.sas.ModelInterface model)
Detaches the current model and attaches the default model if the model is set to null

Specified by:
detachModel in interface com.sas.ViewInterface
Overrides:
detachModel in class CheckBoxVisualComponent
Parameters:
model - Model to detach
See Also:
ViewInterface.detachModel(com.sas.ModelInterface)

getRequiredInterfaces

public java.util.Vector getRequiredInterfaces()
Returns the required interfaces Vector for this component.

Specified by:
getRequiredInterfaces in interface com.sas.ViewInterface
Overrides:
getRequiredInterfaces in class CheckBoxVisualComponent
Returns:
the required interfaces Vector for this component.
See Also:
ViewInterface.getRequiredInterfaces()

getText

public java.lang.String getText()
Returns the CheckBox text. This method is an alias for getLabel().

Specified by:
getText in interface com.sas.lang.StringDataInterface
Returns:
CheckBox text
See Also:
setText(java.lang.String)

isDefaultModelAttached

public boolean isDefaultModelAttached()
Returns whether the default model is attached.

Specified by:
isDefaultModelAttached in interface com.sas.ViewDefaultModelInterface
Returns:
whether the default model is attached.

isResizeToFit

public boolean isResizeToFit()
Returns the value of the resizeToFit property The resizeToFit property determines whether to change the size of the component when either the text or font changes.

Specified by:
isResizeToFit in interface ResizeToFitInterface
Returns:
value of the resizeToFit property
See Also:
setResizeToFit(boolean)

isSelected

public boolean isSelected()
Returns the current state of the checkBox. This method is an alias for getState().

Returns:
current state of the checkBox
See Also:
setSelected(boolean)

processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent e)
Processes item events occurring on this component.Subclasses should always call super so that events are delivered to any ItemListeners.

Overrides:
processItemEvent in class java.awt.Checkbox
Parameters:
e - event to be handled

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Processes a PropertyChangeEvent sent by the model.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class CheckBoxVisualComponent
Parameters:
event - The event from the model indicating what property changed
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

refresh

public void refresh()
Sets value of selected property from the value obtained from the attached model


refresh

public void refresh(com.sas.ModelInterface model)
Sets value of selected property from the value obtained from the attached model

Specified by:
refresh in interface com.sas.ViewInterface
Overrides:
refresh in class CheckBoxVisualComponent
Parameters:
model - attached model
See Also:
ViewInterface.refresh(com.sas.ModelInterface)

setCheckboxGroup

public void setCheckboxGroup(java.awt.CheckboxGroup g)
Sets the CheckboxGroup. A CheckboxGroup allows only one checkBox within the group to be selected at any given time.

Overrides:
setCheckboxGroup in class java.awt.Checkbox
Parameters:
g - an instance of java.awt.CheckBoxGroup to add the checkBox to

setDefaultValues

public void setDefaultValues()
Sets the initial values to the default values. This method is called by the Component constructors. The setDefaultValues method of each class is responsible for setting its own initial values.

Specified by:
setDefaultValues in interface VisualInterface
Specified by:
setDefaultValues in interface com.sas.ComponentInterface
Overrides:
setDefaultValues in class CheckBoxVisualComponent
See Also:
ComponentInterface.setDefaultValues()

setFont

public void setFont(java.awt.Font font)
Sets the font to be used by the component for displaying text.

Specified by:
setFont in interface VisualInterface
Overrides:
setFont in class CheckBoxVisualComponent
Parameters:
font - font
See Also:
Component.setFont(java.awt.Font), CheckBoxVisualComponent.getFont()

setLabel

public void setLabel(java.lang.String text)
Sets the CheckBox with the specified text

Overrides:
setLabel in class java.awt.Checkbox
Parameters:
text - CheckBox text
See Also:
Checkbox.getLabel()

setResizeToFit

public void setResizeToFit(boolean resizeToFit)
Sets the value of the resizeToFit property. The resizeToFit property determines whether to change the size of the component when either the text or font changes. If the component is managed by a layout manager that uses preferred sizes, the component will behave as if the resizeToFit property has been set to true regardless of the actual value of the resizeToFit property.

Specified by:
setResizeToFit in interface ResizeToFitInterface
Parameters:
resizeToFit - boolean value
See Also:
isResizeToFit()

setSelected

public void setSelected(boolean state)
Sets the CheckBox to the specified boolean state. This method is an alias for setState(boolean).

Parameters:
state - boolean state
See Also:
isSelected()

setState

public void setState(boolean state)
Sets the CheckBox to the specified boolean state

Overrides:
setState in class java.awt.Checkbox
Parameters:
state - boolean state
#getState -

setText

public void setText(java.lang.String text)
Sets the CheckBox with the specified text. This method is an alias for setLabel(String).

Specified by:
setText in interface com.sas.lang.StringDataInterface
Parameters:
text - CheckBox text
See Also:
getText()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.