nextapp.echo
Class ToggleButton

java.lang.Object
  extended by nextapp.echo.AbstractComponent
      extended by nextapp.echo.AbstractButton
          extended by nextapp.echo.ToggleButton
All Implemented Interfaces:
java.io.Serializable, Component, ToolTipSupport
Direct Known Subclasses:
CheckBox, RadioButton

public abstract class ToggleButton
extends AbstractButton

A base class for stateful buttons, such as radio buttons and checkboxes.

See Also:
Serialized Form

Nested Class Summary
static class ToggleButton.ToggleButtonModel
          A ButtonModel for buttons that may be selected.
 
Field Summary
static java.lang.String HORIZONTAL_STATE_ALIGNMENT_CHANGED_PROPERTY
           
static java.lang.String HORIZONTAL_STATE_POSITION_CHANGED_PROPERTY
           
static java.lang.String STATE_MARGIN_CHANGED_PROPERTY
           
static java.lang.String STYLE_HORIZONTAL_STATE_ALIGNMENT
          A style constant for the Horizontal State Alignment property.
static java.lang.String STYLE_HORIZONTAL_STATE_POSITION
          A style constant for the Horizontal State Position property.
static java.lang.String STYLE_STATE_MARGIN
          A style constant for the State Margin property.
static java.lang.String STYLE_VERTICAL_STATE_ALIGNMENT
          A style constant for the Vertical State Alignment property.
static java.lang.String STYLE_VERTICAL_STATE_POSITION
          A style constant for the Vertical State Position property.
static java.lang.String VERTICAL_STATE_ALIGNMENT_CHANGED_PROPERTY
           
static java.lang.String VERTICAL_STATE_POSITION_CHANGED_PROPERTY
           
 
Fields inherited from class nextapp.echo.AbstractButton
ACTION_COMMAND_CHANGED_PROPERTY, CSS_CLASS_CHANGED_PROPERTY, DISABLED_CSS_CLASS_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, ICON_TEXT_MARGIN_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, NOTABSTOP_CHANGED_PROPERTY, ROLLOVER_BACKGROUND_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_FONT_CHANGED_PROPERTY, ROLLOVER_FOREGROUND_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, STYLE_HORIZONTAL_ALIGNMENT, STYLE_HORIZONTAL_TEXT_POSITION, STYLE_ICON_TEXT_MARGIN, STYLE_ROLLOVER_BACKGROUND, STYLE_ROLLOVER_ENABLED, STYLE_ROLLOVER_FONT, STYLE_ROLLOVER_FOREGROUND, STYLE_VERTICAL_ALIGNMENT, STYLE_VERTICAL_TEXT_POSITION, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from interface nextapp.echo.ToolTipSupport
TOOL_TIP_TEXT_CHANGED_PROPERTY
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
ToggleButton()
          Creates an initially unselected toggle button with no text or image.
ToggleButton(ImageReference icon)
          Creates a initially unselected toggle button with the specified icon.
ToggleButton(ImageReference icon, boolean selected)
          Creates a toggle button with the specified icon and selection state.
ToggleButton(java.lang.String text)
          Creates an initially unselected toggle button with the specified text.
ToggleButton(java.lang.String text, boolean selected)
          Creates a toggle button with the specified text and selection state.
ToggleButton(java.lang.String text, ImageReference icon, boolean selected)
          Creates a toggle button with the specified text, icon and selection state.
 
Method Summary
 void applyStyle(Style style)
          Sets stylistic properties of this component based on a Style object.
 int getHorizontalStateAlignment()
          Returns the horizontal alignment of the state indicator (check box or radio button) relative to the button.
 int getHorizontalStatePosition()
          Returns the horizontal position of the state indicator (check box or radio button) relative to the button.
 int getStateMargin()
          Returns the size of the margin to be displayed between the state indicator of the toggle button and its icon and text.
 int getVerticalStateAlignment()
          Returns the vertical alignment of the state indicator (check box or radio button) relative to the button.
 int getVerticalStatePosition()
          Returns the vertical position of the state indicator (check box or radio button) relative to the button.
 void setHorizontalStateAlignment(int newValue)
          Sets the horizontal alignment of the state indicator relative to the button.
 void setHorizontalStatePosition(int newValue)
          Sets the horizontal position of the state indicator relative to the button.
 void setStateMargin(int newValue)
          Sets the size of the margin to be displayed between the state indicator of the toggle button and its icon and text.
 void setVerticalStateAlignment(int newValue)
          Sets the vertical alignment of the state indicator relative to the button.
 void setVerticalStatePosition(int newValue)
          Sets the vertical position of the state indicator relative to the button.
 
Methods inherited from class nextapp.echo.AbstractButton
addActionListener, addChangeListener, addItemListener, doAction, fireActionPerformed, fireItemStateChanged, fireStateChanged, getActionCommand, getCssClass, getCssClassDisabled, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextMargin, getModel, getRolloverBackground, getRolloverFont, getRolloverForeground, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getText, getToolTipText, getVerticalAlignment, getVerticalTextPosition, hasActionListeners, isAsync, isNoTabStop, isRolloverEnabled, isSelected, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setAsync, setCssClass, setCssClassDisabled, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextMargin, setModel, setNoTabStop, setRolloverBackground, setRolloverEnabled, setRolloverFont, setRolloverForeground, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setToolTipText, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class nextapp.echo.AbstractComponent
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setClientId, setEnabled, setFocused, setFont, setForeground, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, setVisible, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_HORIZONTAL_STATE_ALIGNMENT

public static final java.lang.String STYLE_HORIZONTAL_STATE_ALIGNMENT
A style constant for the Horizontal State Alignment property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_HORIZONTAL_STATE_POSITION

public static final java.lang.String STYLE_HORIZONTAL_STATE_POSITION
A style constant for the Horizontal State Position property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_STATE_MARGIN

public static final java.lang.String STYLE_STATE_MARGIN
A style constant for the State Margin property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_VERTICAL_STATE_ALIGNMENT

public static final java.lang.String STYLE_VERTICAL_STATE_ALIGNMENT
A style constant for the Vertical State Alignment property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_VERTICAL_STATE_POSITION

public static final java.lang.String STYLE_VERTICAL_STATE_POSITION
A style constant for the Vertical State Position property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

HORIZONTAL_STATE_ALIGNMENT_CHANGED_PROPERTY

public static final java.lang.String HORIZONTAL_STATE_ALIGNMENT_CHANGED_PROPERTY
See Also:
Constant Field Values

HORIZONTAL_STATE_POSITION_CHANGED_PROPERTY

public static final java.lang.String HORIZONTAL_STATE_POSITION_CHANGED_PROPERTY
See Also:
Constant Field Values

STATE_MARGIN_CHANGED_PROPERTY

public static final java.lang.String STATE_MARGIN_CHANGED_PROPERTY
See Also:
Constant Field Values

VERTICAL_STATE_ALIGNMENT_CHANGED_PROPERTY

public static final java.lang.String VERTICAL_STATE_ALIGNMENT_CHANGED_PROPERTY
See Also:
Constant Field Values

VERTICAL_STATE_POSITION_CHANGED_PROPERTY

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

ToggleButton

public ToggleButton()
Creates an initially unselected toggle button with no text or image.


ToggleButton

public ToggleButton(java.lang.String text)
Creates an initially unselected toggle button with the specified text.

Parameters:
text - The text to be displayed in the button.

ToggleButton

public ToggleButton(java.lang.String text,
                    boolean selected)
Creates a toggle button with the specified text and selection state.

Parameters:
text - The text to be displayed in the button.
selected - The selection state of the toggle button.

ToggleButton

public ToggleButton(ImageReference icon)
Creates a initially unselected toggle button with the specified icon.

Parameters:
icon - The icon to be displayed in the button.

ToggleButton

public ToggleButton(ImageReference icon,
                    boolean selected)
Creates a toggle button with the specified icon and selection state.

Parameters:
icon - The icon to be displayed in the button.
selected - The selection state of the toggle button.

ToggleButton

public ToggleButton(java.lang.String text,
                    ImageReference icon,
                    boolean selected)
Creates a toggle button with the specified text, icon and selection state.

Parameters:
text - The text to be displayed in the button.
icon - The icon to be displayed in the button.
selected - The selection state of the toggle button.
Method Detail

applyStyle

public void applyStyle(Style style)
Description copied from interface: Component
Sets stylistic properties of this component based on a Style object. The version of this method in Component will set foreground and background colors and the font from the style if they are present. Components should override this method if they allow more properties to be set from a style object, and should call super.applyStyle() if necessary.

Specified by:
applyStyle in interface Component
Overrides:
applyStyle in class AbstractButton
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(Style)

getHorizontalStateAlignment

public int getHorizontalStateAlignment()
Returns the horizontal alignment of the state indicator (check box or radio button) relative to the button.

Returns:
The horizontal alignment of the state indicator relative to the button, one of the following values:
  • EchoConstants.LEFT
  • EchoConstants.CENTER (the default)
  • EchoConstants.RIGHT

getHorizontalStatePosition

public int getHorizontalStatePosition()
Returns the horizontal position of the state indicator (check box or radio button) relative to the button.

Returns:
The horizontal position of the state indicator relative to the button, one of the following values:
  • EchoConstants.LEFT (the default)
  • EchoConstants.CENTER
  • EchoConstants.RIGHT

getStateMargin

public int getStateMargin()
Returns the size of the margin to be displayed between the state indicator of the toggle button and its icon and text.

Returns:
The size of the margin between the state indicator and the toggle button's icon and text, in pixels.

getVerticalStateAlignment

public int getVerticalStateAlignment()
Returns the vertical alignment of the state indicator (check box or radio button) relative to the button.

Returns:
The alignment position of the state indicator relative to the button, one of the following values:
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

getVerticalStatePosition

public int getVerticalStatePosition()
Returns the vertical position of the state indicator (check box or radio button) relative to the button.

Returns:
The vertical position of the state indicator relative to the button, one of the following values:
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

setHorizontalStateAlignment

public void setHorizontalStateAlignment(int newValue)
Sets the horizontal alignment of the state indicator relative to the button.

Parameters:
newValue - The horizontal alignment of the state indicator relative to the button, one of the following values.
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

setHorizontalStatePosition

public void setHorizontalStatePosition(int newValue)
Sets the horizontal position of the state indicator relative to the button.

Parameters:
newValue - The horizontal position of the state indicator relative to the button, one of the following values.
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

setStateMargin

public void setStateMargin(int newValue)
Sets the size of the margin to be displayed between the state indicator of the toggle button and its icon and text.

Parameters:
newValue - The size of the margin between the state indicator and the toggle button's icon and text, in pixels.

setVerticalStateAlignment

public void setVerticalStateAlignment(int newValue)
Sets the vertical alignment of the state indicator relative to the button.

Parameters:
newValue - The vertical alignment of the state indicator relative to the button, one of the following values.
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

setVerticalStatePosition

public void setVerticalStatePosition(int newValue)
Sets the vertical position of the state indicator relative to the button.

Parameters:
newValue - The vertical position of the state indicator relative to the button, one of the following values.
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM