nextapp.echo
Class AbstractButton

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

public abstract class AbstractButton
extends AbstractComponent
implements ToolTipSupport

A base class from which various types of buttons (simple buttons, radio buttons, checkboxes, etc.) are derived.

See Also:
Serialized Form

Field Summary
static java.lang.String ACTION_COMMAND_CHANGED_PROPERTY
           
static java.lang.String CSS_CLASS_CHANGED_PROPERTY
           
static java.lang.String DISABLED_CSS_CLASS_CHANGED_PROPERTY
           
static java.lang.String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
           
static java.lang.String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
           
static java.lang.String ICON_CHANGED_PROPERTY
           
static java.lang.String ICON_TEXT_MARGIN_CHANGED_PROPERTY
           
static java.lang.String MODEL_CHANGED_PROPERTY
           
static java.lang.String NOTABSTOP_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_BACKGROUND_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_ENABLED_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_FONT_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_FOREGROUND_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_ICON_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
           
static java.lang.String SELECTED_CHANGED_PROPERTY
           
static java.lang.String SELECTED_ICON_CHANGED_PROPERTY
           
static java.lang.String STYLE_HORIZONTAL_ALIGNMENT
          A style constant for the Horizontal Alignment property.
static java.lang.String STYLE_HORIZONTAL_TEXT_POSITION
          A style constant for the Horizontal Text Position property.
static java.lang.String STYLE_ICON_TEXT_MARGIN
          A style constant for the Icon-Text Margin property.
static java.lang.String STYLE_ROLLOVER_BACKGROUND
          A style constant for the Rollover Background property.
static java.lang.String STYLE_ROLLOVER_ENABLED
          A style constant for the Rollover Enabled property.
static java.lang.String STYLE_ROLLOVER_FONT
          A style constant for the Rollover Font property.
static java.lang.String STYLE_ROLLOVER_FOREGROUND
          A style constant for the Rollover Foreground property.
static java.lang.String STYLE_VERTICAL_ALIGNMENT
          A style constant for the Vertical Alignment property.
static java.lang.String STYLE_VERTICAL_TEXT_POSITION
          A style constant for the Vertical Text Position property.
static java.lang.String TEXT_CHANGED_PROPERTY
           
static java.lang.String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
           
static java.lang.String 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
AbstractButton()
          Default constructor.
 
Method Summary
 void addActionListener(ActionListener l)
          Adds an ActionListener to the button.
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener to the button.
 void addItemListener(ItemListener l)
          Adds a ItemListener to the button.
 void applyStyle(Style style)
          Sets stylistic properties of this component based on a Style object.
 void doAction()
          Programmatically performs a click/activation of the button.
 void fireActionPerformed(ActionEvent e)
          Notifies all listeners that have registered for this event type.
 void fireItemStateChanged(ItemEvent e)
          Notifies all listeners that have registered for this event type.
 void fireStateChanged()
          Notifies all listeners that have registered for this event type.
 java.lang.String getActionCommand()
          Returns the action command for this button.
 java.lang.String getCssClass()
           
 java.lang.String getCssClassDisabled()
           
 int getHorizontalAlignment()
          Returns the horizontal alignment of the text relative to the icon.
 int getHorizontalTextPosition()
          Returns the horizontal position of the text relative to the icon.
 ImageReference getIcon()
          Returns the icon.
 int getIconTextMargin()
          Returns the size of the margin to be displayed between the icon and text The margin is only drawn if both icon and text are present.
 ButtonModel getModel()
          Returns the model that this button represents.
 Color getRolloverBackground()
          Returns the rollover background color of the button.
 Font getRolloverFont()
          Returns the rollover font of the button.
 Color getRolloverForeground()
          Returns the rollover foreground color of the button.
 ImageReference getRolloverIcon()
          Returns the rollover icon.
 ImageReference getRolloverSelectedIcon()
          Returns the rollover selected icon.
 ImageReference getSelectedIcon()
          Returns the selected icon.
 java.lang.String getText()
          Returns the text.
 java.lang.String getToolTipText()
          Returns the default tool tip text.
 int getVerticalAlignment()
          Returns the vertical alignment of the text relative to the icon.
 int getVerticalTextPosition()
          Returns the vertical position of the text relative to the icon.
 boolean hasActionListeners()
          Returns true if the button has one or more action listeners.
 boolean isAsync()
           
 boolean isNoTabStop()
           
 boolean isRolloverEnabled()
          Returns whether rollovers are enabled.
 boolean isSelected()
          Returns the button's selection state.
 void removeActionListener(ActionListener l)
          Removes an ActionListener from the button.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from the button.
 void removeItemListener(ItemListener l)
          Removes a ItemListener from the button.
 void setActionCommand(java.lang.String newValue)
          Sets the button's action command.
 void setAsync(boolean async)
           
 void setCssClass(java.lang.String cssClass)
           
 void setCssClassDisabled(java.lang.String cssClass)
           
 void setHorizontalAlignment(int newValue)
          Sets the horizontal alignment of the text relative to the icon.
 void setHorizontalTextPosition(int newValue)
          Sets the horizontal position of the text relative to the icon.
 void setIcon(ImageReference newValue)
          Sets the default icon.
 void setIconTextMargin(int newValue)
          Sets the size of the margin to be displayed between the icon and text.
 void setModel(ButtonModel newValue)
          Sets the model that this button represents.
 void setNoTabStop(boolean newValue)
           
 void setRolloverBackground(Color newValue)
          Sets the rollover background.
 void setRolloverEnabled(boolean newValue)
          Sets whether rollovers are enabled.
 void setRolloverFont(Font newValue)
          Sets the rollover font.
 void setRolloverForeground(Color newValue)
          Sets the rollover foreground.
 void setRolloverIcon(ImageReference newValue)
          Sets the rollover icon.
 void setRolloverSelectedIcon(ImageReference newValue)
          Sets the rollover selected icon.
 void setSelected(boolean newValue)
          Sets the button's selection state.
 void setSelectedIcon(ImageReference newValue)
          Sets the selected icon.
 void setText(java.lang.String newValue)
          Sets the text.
 void setToolTipText(java.lang.String newValue)
          Sets the default tool tip text.
 void setVerticalAlignment(int newValue)
          Sets the vertical alignment of the text relative to the icon.
 void setVerticalTextPosition(int newValue)
          Sets the vertical position of the text relative to the icon.
 
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_ALIGNMENT

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

See Also:
Constant Field Values

STYLE_HORIZONTAL_TEXT_POSITION

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

See Also:
Constant Field Values

STYLE_ICON_TEXT_MARGIN

public static final java.lang.String STYLE_ICON_TEXT_MARGIN
A style constant for the Icon-Text Margin property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_ROLLOVER_BACKGROUND

public static final java.lang.String STYLE_ROLLOVER_BACKGROUND
A style constant for the Rollover Background property. Values of this key must be of type nextapp.echo.Color.

See Also:
Constant Field Values

STYLE_ROLLOVER_ENABLED

public static final java.lang.String STYLE_ROLLOVER_ENABLED
A style constant for the Rollover Enabled property. Values of this key must be of type java.lang.Boolean.

See Also:
Constant Field Values

STYLE_ROLLOVER_FONT

public static final java.lang.String STYLE_ROLLOVER_FONT
A style constant for the Rollover Font property. Values of this key must be of type nextapp.echo.Font.

See Also:
Constant Field Values

STYLE_ROLLOVER_FOREGROUND

public static final java.lang.String STYLE_ROLLOVER_FOREGROUND
A style constant for the Rollover Foreground property. Values of this key must be of type nextapp.echo.Color.

See Also:
Constant Field Values

STYLE_VERTICAL_ALIGNMENT

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

See Also:
Constant Field Values

STYLE_VERTICAL_TEXT_POSITION

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

See Also:
Constant Field Values

ACTION_COMMAND_CHANGED_PROPERTY

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

HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY

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

HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY

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

ICON_CHANGED_PROPERTY

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

ICON_TEXT_MARGIN_CHANGED_PROPERTY

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

MODEL_CHANGED_PROPERTY

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

ROLLOVER_BACKGROUND_CHANGED_PROPERTY

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

ROLLOVER_ENABLED_CHANGED_PROPERTY

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

ROLLOVER_FONT_CHANGED_PROPERTY

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

ROLLOVER_FOREGROUND_CHANGED_PROPERTY

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

ROLLOVER_ICON_CHANGED_PROPERTY

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

ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY

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

SELECTED_CHANGED_PROPERTY

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

SELECTED_ICON_CHANGED_PROPERTY

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

TEXT_CHANGED_PROPERTY

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

VERTICAL_ALIGNMENT_CHANGED_PROPERTY

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

VERTICAL_TEXT_POSITION_CHANGED_PROPERTY

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

NOTABSTOP_CHANGED_PROPERTY

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

CSS_CLASS_CHANGED_PROPERTY

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

DISABLED_CSS_CLASS_CHANGED_PROPERTY

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

AbstractButton

public AbstractButton()
Default constructor.

Method Detail

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener to the button.

Parameters:
l - The ActionListener to be added.

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the button.

Parameters:
l - The ChangeListener to be added.

addItemListener

public void addItemListener(ItemListener l)
Adds a ItemListener to the button.

Parameters:
l - The ItemListener to be added.

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 AbstractComponent
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(Style)

doAction

public void doAction()
Programmatically performs a click/activation of the button.


fireActionPerformed

public void fireActionPerformed(ActionEvent e)
Notifies all listeners that have registered for this event type.

Parameters:
e - The ActionEvent to send.

fireItemStateChanged

public void fireItemStateChanged(ItemEvent e)
Notifies all listeners that have registered for this event type.

Parameters:
e - The ItemEvent to send.

fireStateChanged

public void fireStateChanged()
Notifies all listeners that have registered for this event type.


getActionCommand

public java.lang.String getActionCommand()
Returns the action command for this button.

Returns:
The action command for this button.

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment of the text relative to the icon.

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

getHorizontalTextPosition

public int getHorizontalTextPosition()
Returns the horizontal position of the text relative to the icon.

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

getIcon

public ImageReference getIcon()
Returns the icon.

Returns:
The icon.

getIconTextMargin

public int getIconTextMargin()
Returns the size of the margin to be displayed between the icon and text The margin is only drawn if both icon and text are present.

Returns:
The size of the margin between the icon and text, in pixels.

getModel

public ButtonModel getModel()
Returns the model that this button represents.

Returns:
The button's model.

getRolloverBackground

public Color getRolloverBackground()
Returns the rollover background color of the button.

Returns:
The rollover background color.

getRolloverFont

public Font getRolloverFont()
Returns the rollover font of the button.

Returns:
The rollover font.

getRolloverForeground

public Color getRolloverForeground()
Returns the rollover foreground color of the button.

Returns:
The rollover foreground color.

getRolloverIcon

public ImageReference getRolloverIcon()
Returns the rollover icon.

Returns:
The rollover icon.

getRolloverSelectedIcon

public ImageReference getRolloverSelectedIcon()
Returns the rollover selected icon.

Returns:
The rollover selected icon.

getSelectedIcon

public ImageReference getSelectedIcon()
Returns the selected icon.

Returns:
The selected icon.

getText

public java.lang.String getText()
Returns the text.

Returns:
The text.

getToolTipText

public java.lang.String getToolTipText()
Description copied from interface: ToolTipSupport
Returns the default tool tip text.

Specified by:
getToolTipText in interface ToolTipSupport
Returns:
The tool tip text.
See Also:
ToolTipSupport.getToolTipText()

getVerticalAlignment

public int getVerticalAlignment()
Returns the vertical alignment of the text relative to the icon.

Returns:
The vertical alignment of the text relative to the icon, one of the following values:
  • EchoConstants.TOP
  • EchoConstants.CENTER (the default)
  • EchoConstants.BOTTOM

getVerticalTextPosition

public int getVerticalTextPosition()
Returns the vertical position of the text relative to the icon.

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

hasActionListeners

public boolean hasActionListeners()
Returns true if the button has one or more action listeners.

Returns:
True if the button has one or more action listeners.

isRolloverEnabled

public boolean isRolloverEnabled()
Returns whether rollovers are enabled.

Returns:
True if rollovers are enabled.

isSelected

public boolean isSelected()
Returns the button's selection state.

Returns:
True if the button is selected.

removeActionListener

public void removeActionListener(ActionListener l)
Removes an ActionListener from the button.

Parameters:
l - The ActionListener to be removed.

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the button.

Parameters:
l - The ChangeListener to be removed.

removeItemListener

public void removeItemListener(ItemListener l)
Removes a ItemListener from the button.

Parameters:
l - The ItemListener to be removed.

setActionCommand

public void setActionCommand(java.lang.String newValue)
Sets the button's action command.

Parameters:
newValue - The new action command for this button.

setHorizontalAlignment

public void setHorizontalAlignment(int newValue)
Sets the horizontal alignment of the text relative to the icon.

Parameters:
newValue - The horizontal alignment of the text relative to the icon, one of the following values:
  • EchoConstants.LEFT (the default)
  • EchoConstants.CENTER
  • EchoConstants.RIGHT

setHorizontalTextPosition

public void setHorizontalTextPosition(int newValue)
Sets the horizontal position of the text relative to the icon.

Parameters:
newValue - The horizontal position of the text relative to the icon, one of the following values.
  • EchoConstants.LEFT
  • EchoConstants.CENTER
  • EchoConstants.RIGHT (the default)

setIcon

public void setIcon(ImageReference newValue)
Sets the default icon.

Parameters:
newValue - The default icon.

setIconTextMargin

public void setIconTextMargin(int newValue)
Sets the size of the margin to be displayed between the icon and text. The margin is only drawn if both icon and text are present.

Parameters:
newValue - The size of the margin between the icon and text, in pixels.

setModel

public void setModel(ButtonModel newValue)
Sets the model that this button represents.

Parameters:
newValue - The new model for this button.

setRolloverBackground

public void setRolloverBackground(Color newValue)
Sets the rollover background.

Parameters:
newValue - The rollover background.

setRolloverEnabled

public void setRolloverEnabled(boolean newValue)
Sets whether rollovers are enabled.

Parameters:
newValue - True if rollovers should be enabled.

setRolloverFont

public void setRolloverFont(Font newValue)
Sets the rollover font.

Parameters:
newValue - The rollover font.

setRolloverForeground

public void setRolloverForeground(Color newValue)
Sets the rollover foreground.

Parameters:
newValue - The rollover foreground.

setRolloverIcon

public void setRolloverIcon(ImageReference newValue)
Sets the rollover icon.

Parameters:
newValue - The rollover icon.

setRolloverSelectedIcon

public void setRolloverSelectedIcon(ImageReference newValue)
Sets the rollover selected icon.

Parameters:
newValue - The rollover selected icon.

setSelected

public void setSelected(boolean newValue)
Sets the button's selection state.

Parameters:
newValue - The new selection state of this button.

setSelectedIcon

public void setSelectedIcon(ImageReference newValue)
Sets the selected icon.

Parameters:
newValue - The selected icon.

setText

public void setText(java.lang.String newValue)
Sets the text.

Parameters:
newValue - The text.

setToolTipText

public void setToolTipText(java.lang.String newValue)
Description copied from interface: ToolTipSupport
Sets the default tool tip text.

Specified by:
setToolTipText in interface ToolTipSupport
Parameters:
newValue - The new tool tip text.
See Also:
ToolTipSupport.setToolTipText(String)

setVerticalAlignment

public void setVerticalAlignment(int newValue)
Sets the vertical alignment of the text relative to the icon.

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

setVerticalTextPosition

public void setVerticalTextPosition(int newValue)
Sets the vertical position of the text relative to the icon.

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

isNoTabStop

public boolean isNoTabStop()

setNoTabStop

public void setNoTabStop(boolean newValue)

getCssClass

public java.lang.String getCssClass()

setCssClass

public void setCssClass(java.lang.String cssClass)

getCssClassDisabled

public java.lang.String getCssClassDisabled()

setCssClassDisabled

public void setCssClassDisabled(java.lang.String cssClass)

isAsync

public boolean isAsync()

setAsync

public void setAsync(boolean async)