javax.swing

Class AbstractButton

Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, SwingConstants
Known Direct Subclasses:
JButton, JMenuItem, JToggleButton

public abstract class AbstractButton
extends JComponent
implements ItemSelectable, SwingConstants

Provides an abstract implementation of common button behaviour, data model and look & feel.

This class is supposed to serve as a base class for several kinds of buttons with similar but non-identical semantics: toggle buttons (radio buttons and checkboxes), simple push buttons, menu items, etc.

Buttons have many properties, some of which are stored in this class while others are delegated to the button's model. The following properties are available:

Property Stored inBound?
action buttonno
actionCommand modelno
borderPainted buttonyes
contentAreaFilled buttonyes
disabledIcon buttonyes
disabledSelectedIcon buttonyes
displayedMnemonicIndex buttonno
enabled modelno
focusPainted buttonyes
horizontalAlignment buttonyes
horizontalTextPosition buttonyes
icon buttonyes
iconTextGap buttonno
label (same as text) modelyes
margin buttonyes
multiClickThreshold buttonno
pressedIcon buttonyes
rolloverEnabled buttonyes
rolloverIcon buttonyes
rolloverSelectedIcon buttonyes
selected modelno
selectedIcon buttonyes
selectedObjects buttonno
text modelyes
UI buttonyes
verticalAlignment buttonyes
verticalTextPosition buttonyes

The various behavioral aspects of these properties follows:

See Also:
Serialized Form

Nested Class Summary

protected abstract class
AbstractButton.AccessibleAbstractButton
A Java Accessibility extension of the AbstractButton.
protected class
AbstractButton.ButtonChangeListener
An extension of ChangeListener to be serializable.

Nested classes/interfaces inherited from class javax.swing.JComponent

JComponent.AccessibleJComponent

Nested classes/interfaces inherited from class java.awt.Container

Container.AccessibleAWTContainer

Nested classes/interfaces inherited from class java.awt.Component

Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy

Field Summary

static String
BORDER_PAINTED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "borderPainted" property changes.
static String
CONTENT_AREA_FILLED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "contentAreaFilled" property changes.
static String
DISABLED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "disabledIcon" property changes.
static String
DISABLED_SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "disabledSelectedIcon" property changes.
static String
FOCUS_PAINTED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "focusPainted" property changes.
static String
HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "horizontalAlignment" property changes.
static String
HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "horizontalTextPosition" property changes.
static String
ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "icon" property changes.
static String
MARGIN_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "margin" property changes.
static String
MNEMONIC_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "mnemonic" property changes.
static String
MODEL_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "model" property changes.
static String
PRESSED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "pressedIcon" property changes.
static String
ROLLOVER_ENABLED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverEnabled" property changes.
static String
ROLLOVER_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverIcon" property changes.
static String
ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverSelectedIcon" property changes.
static String
SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "selectedIcon" property changes.
static String
TEXT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "text" property changes.
static String
VERTICAL_ALIGNMENT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "verticalAlignment" property changes.
static String
VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "verticalTextPosition" property changes.
protected ActionListener
actionListener
Listener the button uses to receive ActionEvents from its model.
protected ChangeEvent
changeEvent
ChangeEvent that is fired to button's ChangeEventListeners
protected ChangeListener
changeListener
Listener the button uses to receive ChangeEvents from its model.
protected ItemListener
itemListener
Listener the button uses to receive ItemEvents from its model.
protected ButtonModel
model
The button's current state.

Fields inherited from class javax.swing.JComponent

TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, accessibleContext, listenerList, ui

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

Fields inherited from interface javax.swing.SwingConstants

BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST

Constructor Summary

AbstractButton()
Creates a new AbstractButton object.

Method Summary

void
addActionListener(ActionListener l)
Adds an ActionListener to the button's listener list.
void
addChangeListener(ChangeListener l)
Adds a ChangeListener to the button's listener list.
protected void
addImpl(Component comp, Object constraints, int index)
Adds the specified component to this AbstractButton.
void
addItemListener(ItemListener l)
Adds an ItemListener to the button's listener list.
protected int
checkHorizontalKey(int key, String exception)
Verifies that a particular key is one of the valid constants used for describing horizontal alignment and positioning.
protected int
checkVerticalKey(int key, String exception)
Verifies that a particular key is one of the valid constants used for describing vertical alignment and positioning.
protected void
configurePropertiesFromAction(Action a)
Configure various properties of the button by reading properties of an Action.
protected ActionListener
createActionListener()
A factory method which should return an ActionListener that propagates events from the button's ButtonModel to any of the button's ActionListeners.
protected PropertyChangeListener
createActionPropertyChangeListener(Action a)
A factory method which should return a PropertyChangeListener that accepts changes to the specified Action and reconfigure the AbstractButton, by default using the configurePropertiesFromAction(Action) method.

The button calls this method whenever a new Action is assigned to the button's "action" property, via setAction(Action), and stores the resulting PropertyChangeListener in its actionPropertyChangeListener member field.

protected ChangeListener
createChangeListener()
Factory method which creates a ChangeListener, used to subscribe to ChangeEvents from the button's model.
protected ItemListener
createItemListener()
Factory method which creates a ItemListener, used to subscribe to ItemEvents from the button's model.
void
doClick()
Programmatically perform a "click" on the button: arming, pressing, waiting, un-pressing, and disarming the model.
void
doClick(int pressTime)
Programmatically perform a "click" on the button: arming, pressing, waiting, un-pressing, and disarming the model.
protected void
fireActionPerformed(ActionEvent e)
Calls ActionListener.actionPerformed(ActionEvent) on each ActionListener in the button's listener list.
protected void
fireItemStateChanged(ItemEvent e)
Calls ItemListener.itemStateChanged(ItemEvent) on each ItemListener in the button's listener list.
protected void
fireStateChanged()
Calls ChangeListener.stateChanged(ChangeEvent) on each ChangeListener in the button's listener list.
Action
getAction()
Get the value of the "action" property.
String
getActionCommand()
Returns the action command string for this button's model.

If the action command was set to null, the button's text (label) is returned instead.

ActionListener[]
getActionListeners()
Returns all added ActionListener objects.
ChangeListener[]
getChangeListeners()
Returns all added ChangeListener objects.
Icon
getDisabledIcon()
Return the button's "disabledIcon" property.
Icon
getDisabledSelectedIcon()
Return the button's disabled selected icon.
int
getDisplayedMnemonicIndex()
Get the button's mnemonic index, which is an offset into the button's "text" property.
int
getHorizontalAlignment()
Set the horizontal alignment of the button's text and icon.
int
getHorizontalTextPosition()
Get the horizontal position of the button's text relative to its icon.
Icon
getIcon()
Return the button's default "icon" property.
int
getIconTextGap()
Get the value of the iconTextGap property.
ItemListener[]
getItemListeners()
Returns all added ItemListener objects.
String
getLabel()
Deprecated. use getText()
Insets
getMargin()
Return the button's "margin" property, which is an Insets object describing the distance between the button's border and its text and icon.
int
getMnemonic()
Get the current keyboard mnemonic value.
ButtonModel
getModel()
Get the model the button is currently using.
long
getMultiClickThreshhold()
Returns the current time in milliseconds in which clicks gets coalesced into a single ActionEvent.
Icon
getPressedIcon()
Return the button's "pressedIcon" property.
Icon
getRolloverIcon()
Return the button's rollover icon.
Icon
getRolloverSelectedIcon()
Return the button's rollover selected icon.
Icon
getSelectedIcon()
Return the button's selected icon.
Object[]
getSelectedObjects()
Returns an single-element array containing the "text" property of the button if the "selected" property of the button's model is true, otherwise returns null.
String
getText()
Return the button's "text" property.
ButtonUI
getUI()
Set the "UI" property of the button, which is a look and feel class responsible for handling the button's input events and painting it.
int
getVerticalAlignment()
Get the vertical alignment of the button's text and icon.
int
getVerticalTextPosition()
Get the vertical position of the button's text relative to its icon.
boolean
imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
Called when image data becomes available for one of the button's icons.
protected void
init(String text, Icon icon)
boolean
isBorderPainted()
Set the value of the "borderPainted" property.
boolean
isContentAreaFilled()
Returns the value of the button's "contentAreaFilled" property.
boolean
isFocusPainted()
Return the button's "paintFocus" property.
boolean
isRolloverEnabled()
Returns whether or not rollover icon changes are enabled on the button.
boolean
isSelected()
Get the value of the button's "selected" property.
protected void
paintBorder(Graphics g)
Paints the button's border, if the button's "borderPainted" property is true, by out calling to the button's look and feel class.
protected String
paramString()
Returns a string, used only for debugging, which identifies or somehow represents this button.
void
removeActionListener(ActionListener l)
Removes an ActionListener from the button's listener list.
void
removeChangeListener(ChangeListener l)
Removes a ChangeListener from the button's listener list.
void
removeItemListener(ItemListener l)
Removes an ItemListener from the button's listener list.
void
setAction(Action a)
Set the button's "action" property, subscribing the new action to the button, as an ActionListener, if it is not already subscribed.
void
setActionCommand(String actionCommand)
Sets the action command string for this button's model.
void
setBorderPainted(boolean b)
Set the value of the "borderPainted" property.
void
setContentAreaFilled(boolean b)
Sets the value of the button's "contentAreaFilled" property.
void
setDisabledIcon(Icon d)
Set the button's "disabledIcon" property.
void
setDisabledSelectedIcon(Icon icon)
Set the button's disabled selected icon.
void
setDisplayedMnemonicIndex(int index)
Sets the button's mnemonic index.
void
setEnabled(boolean b)
Enables or disables the button.
void
setFocusPainted(boolean p)
Set the button's "paintFocus" property.
void
setHorizontalAlignment(int a)
Set the horizontal alignment of the button's text and icon.
void
setHorizontalTextPosition(int t)
Set the horizontal position of the button's text relative to its icon.
void
setIcon(Icon i)
Set the button's default "icon" property.
void
setIconTextGap(int i)
Set the value of the iconTextGap property.
void
setLabel(String label)
Deprecated. use setText(text)
void
setLayout(LayoutManager layout)
Sets a layout manager on this AbstractButton.
void
setMargin(Insets m)
Set the button's "margin" property, which is an Insets object describing the distance between the button's border and its text and icon.
void
setMnemonic(char mne)
Set the current keyboard mnemonic value.
void
setMnemonic(int mne)
Set the current keyboard mnemonic value.
void
setModel(ButtonModel newModel)
Set the model the button is currently using.
void
setMultiClickThreshhold(long threshhold)
Sets the time in milliseconds in which clicks gets coalesced into a single ActionEvent.
void
setPressedIcon(Icon pressedIcon)
Set the button's "pressedIcon" property.
void
setRolloverEnabled(boolean r)
Set the "rolloverEnabled" property.
void
setRolloverIcon(Icon r)
Set the button's rollover icon and sets the rolloverEnabled property to true.
void
setRolloverSelectedIcon(Icon r)
Set the button's rollover selected icon and sets the rolloverEnabled property to true.
void
setSelected(boolean s)
Set the value of the button's "selected" property.
void
setSelectedIcon(Icon s)
Set the button's selected icon.
void
setText(String t)
Set the button's "text" property.
void
setUI(ButtonUI ui)
Set the "UI" property of the button, which is a look and feel class responsible for handling the button's input events and painting it.
void
setVerticalAlignment(int a)
Set the vertical alignment of the button's text and icon.
void
setVerticalTextPosition(int t)
Set the vertical position of the button's text relative to its icon.
void
updateUI()
Set the "UI" property to a class constructed, via the UIManager, from the current look and feel.

Methods inherited from class javax.swing.JComponent

addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI

Methods inherited from class java.awt.Container

add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree

Methods inherited from class java.awt.Component

action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

BORDER_PAINTED_CHANGED_PROPERTY

public static final String BORDER_PAINTED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "borderPainted" property changes.
Field Value:
"borderPainted"

CONTENT_AREA_FILLED_CHANGED_PROPERTY

public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "contentAreaFilled" property changes.
Field Value:
"contentAreaFilled"

DISABLED_ICON_CHANGED_PROPERTY

public static final String DISABLED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "disabledIcon" property changes.
Field Value:
"disabledIcon"

DISABLED_SELECTED_ICON_CHANGED_PROPERTY

public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "disabledSelectedIcon" property changes.
Field Value:
"disabledSelectedIcon"

FOCUS_PAINTED_CHANGED_PROPERTY

public static final String FOCUS_PAINTED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "focusPainted" property changes.
Field Value:
"focusPainted"

HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY

public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "horizontalAlignment" property changes.
Field Value:
"horizontalAlignment"

HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY

public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "horizontalTextPosition" property changes.
Field Value:
"horizontalTextPosition"

ICON_CHANGED_PROPERTY

public static final String ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "icon" property changes.
Field Value:
"icon"

MARGIN_CHANGED_PROPERTY

public static final String MARGIN_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "margin" property changes.
Field Value:
"margin"

MNEMONIC_CHANGED_PROPERTY

public static final String MNEMONIC_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "mnemonic" property changes.
Field Value:
"mnemonic"

MODEL_CHANGED_PROPERTY

public static final String MODEL_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "model" property changes.
Field Value:
"model"

PRESSED_ICON_CHANGED_PROPERTY

public static final String PRESSED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "pressedIcon" property changes.
Field Value:
"pressedIcon"

ROLLOVER_ENABLED_CHANGED_PROPERTY

public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverEnabled" property changes.
Field Value:
"rolloverEnabled"

ROLLOVER_ICON_CHANGED_PROPERTY

public static final String ROLLOVER_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverIcon" property changes.
Field Value:
"rolloverIcon"

ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY

public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverSelectedIcon" property changes.
Field Value:
"rolloverSelectedIcon"

SELECTED_ICON_CHANGED_PROPERTY

public static final String SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "selectedIcon" property changes.
Field Value:
"selectedIcon"

TEXT_CHANGED_PROPERTY

public static final String TEXT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "text" property changes.
Field Value:
"text"

VERTICAL_ALIGNMENT_CHANGED_PROPERTY

public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "verticalAlignment" property changes.
Field Value:
"verticalAlignment"

VERTICAL_TEXT_POSITION_CHANGED_PROPERTY

public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "verticalTextPosition" property changes.
Field Value:
"verticalTextPosition"

actionListener

protected ActionListener actionListener
Listener the button uses to receive ActionEvents from its model.

changeEvent

protected ChangeEvent changeEvent
ChangeEvent that is fired to button's ChangeEventListeners

changeListener

protected ChangeListener changeListener
Listener the button uses to receive ChangeEvents from its model.

itemListener

protected ItemListener itemListener
Listener the button uses to receive ItemEvents from its model.

model

protected ButtonModel model
The button's current state.

Constructor Details

AbstractButton

public AbstractButton()
Creates a new AbstractButton object. Subclasses should call the following sequence in their constructor in order to initialize the button correctly:
 super();
 init(text, icon);
 
The init(String,Icon) method is not called automatically by this constructor.

Method Details

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener to the button's listener list. When the button's model is clicked it fires an ActionEvent, and these listeners will be called.
Parameters:
l - The new listener to add

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the button's listener list. When the button's model changes any of its (non-bound) properties, these listeners will be called.
Parameters:
l - The new listener to add

addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
Adds the specified component to this AbstractButton. This overrides the default in order to install an OverlayLayout layout manager before adding the component. The layout manager is only installed if no other layout manager has been installed before.
Overrides:
addImpl in interface Container
Parameters:
comp - the component to be added
constraints - constraints for the layout manager
index - the index at which the component is added
Since:
1.5

addItemListener

public void addItemListener(ItemListener l)
Adds an ItemListener to the button's listener list. When the button's model changes state (between any of ARMED, ENABLED, PRESSED, ROLLOVER or SELECTED) it fires an ItemEvent, and these listeners will be called.
Specified by:
addItemListener in interface ItemSelectable
Parameters:
l - The new listener to add

checkHorizontalKey

protected int checkHorizontalKey(int key,
                                 String exception)
Verifies that a particular key is one of the valid constants used for describing horizontal alignment and positioning. The valid constants are the following members of SwingConstants: RIGHT, LEFT, CENTER, LEADING or TRAILING.
Parameters:
key - The key to check
exception - A message to include in an IllegalArgumentException
Returns:
the value of key
Throws:
IllegalArgumentException - If key is not one of the valid constants

checkVerticalKey

protected int checkVerticalKey(int key,
                               String exception)
Verifies that a particular key is one of the valid constants used for describing vertical alignment and positioning. The valid constants are the following members of SwingConstants: TOP, BOTTOM or CENTER.
Parameters:
key - The key to check
exception - A message to include in an IllegalArgumentException
Returns:
the value of key
Throws:
IllegalArgumentException - If key is not one of the valid constants

configurePropertiesFromAction

protected void configurePropertiesFromAction(Action a)
Configure various properties of the button by reading properties of an Action. The mapping of properties is as follows:
Action keyed propertyAbstractButton property
NAME text
SMALL_ICON icon
SHORT_DESCRIPTION toolTipText
MNEMONIC_KEY mnemonic
ACTION_COMMAND_KEY actionCommand

In addition, this method always sets the button's "enabled" property to the value of the Action's "enabled" property.

If the provided Action is null, the text, icon, and toolTipText properties of the button are set to null, and the "enabled" property is set to true; the mnemonic and actionCommand properties are unchanged.

Parameters:
a - An Action to configure the button from

createActionListener

protected ActionListener createActionListener()
A factory method which should return an ActionListener that propagates events from the button's ButtonModel to any of the button's ActionListeners. By default, this is an inner class which calls fireActionPerformed(ActionEvent) with a modified copy of the incoming model ActionEvent.

The button calls this method during construction, stores the resulting ActionListener in its actionListener member field, and subscribes it to the button's model. If the button's model is changed, this listener is unsubscribed from the old model and subscribed to the new one.

Returns:
A new ActionListener

createActionPropertyChangeListener

protected PropertyChangeListener createActionPropertyChangeListener(Action a)
A factory method which should return a PropertyChangeListener that accepts changes to the specified Action and reconfigure the AbstractButton, by default using the configurePropertiesFromAction(Action) method.

The button calls this method whenever a new Action is assigned to the button's "action" property, via setAction(Action), and stores the resulting PropertyChangeListener in its actionPropertyChangeListener member field. The button then subscribes the listener to the button's new action. If the button's action is changed subsequently, the listener is unsubscribed from the old action and subscribed to the new one.

Parameters:
a - The Action which will be listened to, and which should be the same as the source of any PropertyChangeEvents received by the new listener returned from this method.
Returns:
A new PropertyChangeListener

createChangeListener

protected ChangeListener createChangeListener()
Factory method which creates a ChangeListener, used to subscribe to ChangeEvents from the button's model. Subclasses of AbstractButton may wish to override the listener used to subscribe to such ChangeEvents. By default, the listener just propagates the ChangeEvent to the button's ChangeListeners, via the fireStateChanged() method.

The button calls this method during construction, stores the resulting ChangeListener in its changeListener member field, and subscribes it to the button's model. If the button's model is changed, this listener is unsubscribed from the old model and subscribed to the new one.

Returns:
The new ChangeListener

createItemListener

protected ItemListener createItemListener()
Factory method which creates a ItemListener, used to subscribe to ItemEvents from the button's model. Subclasses of AbstractButton may wish to override the listener used to subscribe to such ItemEvents. By default, the listener just propagates the ItemEvent to the button's ItemListeners, via the fireItemStateChanged(ItemEvent) method.

The button calls this method during construction, stores the resulting ItemListener in its changeListener member field, and subscribes it to the button's model. If the button's model is changed, this listener is unsubscribed from the old model and subscribed to the new one.

Note that ItemEvents are only generated from the button's model when the model's selected property changes. If you want to subscribe to other properties of the model, you must subscribe to ChangeEvents.

Returns:
The new ItemListener

doClick

public void doClick()
Programmatically perform a "click" on the button: arming, pressing, waiting, un-pressing, and disarming the model.

doClick

public void doClick(int pressTime)
Programmatically perform a "click" on the button: arming, pressing, waiting, un-pressing, and disarming the model.
Parameters:
pressTime - The number of milliseconds to wait in the pressed state

fireActionPerformed

protected void fireActionPerformed(ActionEvent e)
Calls ActionListener.actionPerformed(ActionEvent) on each ActionListener in the button's listener list.
Parameters:
e - The event signifying that the button's model was clicked

fireItemStateChanged

protected void fireItemStateChanged(ItemEvent e)
Calls ItemListener.itemStateChanged(ItemEvent) on each ItemListener in the button's listener list.
Parameters:
e - The event signifying that the button's model changed state

fireStateChanged

protected void fireStateChanged()
Calls ChangeListener.stateChanged(ChangeEvent) on each ChangeListener in the button's listener list.

getAction

public Action getAction()
Get the value of the "action" property.
Returns:
The current value of the "action" property

getActionCommand

public String getActionCommand()
Returns the action command string for this button's model.

If the action command was set to null, the button's text (label) is returned instead.

Returns:
The current action command string from the button's model

getActionListeners

public ActionListener[] getActionListeners()
Returns all added ActionListener objects.
Returns:
an array of listeners
Since:
1.4

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns all added ChangeListener objects.
Returns:
an array of listeners
Since:
1.4

getDisabledIcon

public Icon getDisabledIcon()
Return the button's "disabledIcon" property. The look and feel class should paint this icon when the "enabled" property of the button's ButtonModel is false. This property may be null, in which case an icon is constructed, based on the default icon.
Returns:
The current "disabledIcon" property

getDisabledSelectedIcon

public Icon getDisabledSelectedIcon()
Return the button's disabled selected icon. The look and feel class should paint this icon when the "enabled" property of the button's model is false and its "selected" property is true. This icon can be null, in which case it is synthesized from the button's selected icon.
Returns:
The current disabled selected icon

getDisplayedMnemonicIndex

public int getDisplayedMnemonicIndex()
Get the button's mnemonic index, which is an offset into the button's "text" property. The character specified by this offset should be underlined when the look and feel class draws this button.
Returns:
An index into the button's "text" property

getHorizontalAlignment

public int getHorizontalAlignment()
Set the horizontal alignment of the button's text and icon. The alignment is a numeric constant from SwingConstants. It must be one of: RIGHT, LEFT, CENTER, LEADING or TRAILING. The default is CENTER.
Returns:
The current horizontal alignment

getHorizontalTextPosition

public int getHorizontalTextPosition()
Get the horizontal position of the button's text relative to its icon. The position is a numeric constant from SwingConstants. It must be one of: RIGHT, LEFT, CENTER, LEADING or TRAILING. The default is TRAILING.
Returns:
The current horizontal text position

getIcon

public Icon getIcon()
Return the button's default "icon" property.
Returns:
The current default icon

getIconTextGap

public int getIconTextGap()
Get the value of the iconTextGap property.
Returns:
The current value of the property
Since:
1.4

getItemListeners

public ItemListener[] getItemListeners()
Returns all added ItemListener objects.
Returns:
an array of listeners
Since:
1.4

getLabel

public String getLabel()

Deprecated. use getText()

Return the button's "label" property. This property is synonymous with the "text" property.
Returns:
The current "label" property

getMargin

public Insets getMargin()
Return the button's "margin" property, which is an Insets object describing the distance between the button's border and its text and icon.
Returns:
The current "margin" property

getMnemonic

public int getMnemonic()
Get the current keyboard mnemonic value. This value corresponds to a single key code (one of the KeyEvent VK_* codes) and is used to activate the button when pressed in conjunction with the "mouseless modifier" of the button's look and feel class, and when focus is in one of the button's ancestors.
Returns:
The button's current keyboard mnemonic

getModel

public ButtonModel getModel()
Get the model the button is currently using.
Returns:
The current model

getMultiClickThreshhold

public long getMultiClickThreshhold()
Returns the current time in milliseconds in which clicks gets coalesced into a single ActionEvent.
Returns:
the time in milliseconds
Since:
1.4

getPressedIcon

public Icon getPressedIcon()
Return the button's "pressedIcon" property. The look and feel class should paint this icon when the "pressed" property of the button's ButtonModel is true. This property may be null, in which case the default icon is used.
Returns:
The current "pressedIcon" property

getRolloverIcon

public Icon getRolloverIcon()
Return the button's rollover icon. The look and feel class should paint this icon when the "rolloverEnabled" property of the button is true and the mouse rolls over the button.
Returns:
The current rollover icon

getRolloverSelectedIcon

public Icon getRolloverSelectedIcon()
Return the button's rollover selected icon. The look and feel class should paint this icon when the "rolloverEnabled" property of the button is true, the "selected" property of the button's model is true, and the mouse rolls over the button.
Returns:
The current rollover selected icon

getSelectedIcon

public Icon getSelectedIcon()
Return the button's selected icon. The look and feel class should paint this icon when the "selected" property of the button's model is true, and either the "rolloverEnabled" property of the button is false or the mouse is not currently rolled over the button.
Returns:
The current selected icon

getSelectedObjects

public Object[] getSelectedObjects()
Returns an single-element array containing the "text" property of the button if the "selected" property of the button's model is true, otherwise returns null.
Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
The button's "selected object" array

getText

public String getText()
Return the button's "text" property. This property is synonymous with the "label" property.
Returns:
The current "text" property

getUI

public ButtonUI getUI()
Set the "UI" property of the button, which is a look and feel class responsible for handling the button's input events and painting it.
Returns:
The current "UI" property

getVerticalAlignment

public int getVerticalAlignment()
Get the vertical alignment of the button's text and icon. The alignment is a numeric constant from SwingConstants. It must be one of: CENTER, TOP, or BOTTOM. The default is CENTER.
Returns:
The current vertical alignment

getVerticalTextPosition

public int getVerticalTextPosition()
Get the vertical position of the button's text relative to its icon. The alignment is a numeric constant from SwingConstants. It must be one of: CENTER, TOP, or BOTTOM. The default is CENTER.
Returns:
The current vertical position

imageUpdate

public boolean imageUpdate(Image img,
                           int infoflags,
                           int x,
                           int y,
                           int w,
                           int h)
Called when image data becomes available for one of the button's icons.
Specified by:
imageUpdate in interface ImageObserver
Overrides:
imageUpdate in interface Component
Parameters:
img - The image being updated
infoflags - One of the constant codes in ImageObserver used to describe updated portions of an image.
x - X coordinate of the region being updated
y - Y coordinate of the region being updated
w - Width of the region beign updated
h - Height of the region being updated
Returns:
true if img is equal to the button's current icon, otherwise false

init

protected void init(String text,
                    Icon icon)

isBorderPainted

public boolean isBorderPainted()
Set the value of the "borderPainted" property. If set to false, the button's look and feel class should not paint a border for the button. The default is true.
Returns:
The current value of the property.

isContentAreaFilled

public boolean isContentAreaFilled()
Returns the value of the button's "contentAreaFilled" property. This property indicates whether the area surrounding the text and icon of the button should be filled by the look and feel class. If this property is false, the look and feel class should leave the content area transparent.
Returns:
The current value of the "contentAreaFilled" property

isFocusPainted

public boolean isFocusPainted()
Return the button's "paintFocus" property. This property controls whether or not the look and feel class will paint a special indicator of focus state for the button. If it is false, the button still paints when focused, but no special decoration is painted to indicate the presence of focus.
Returns:
The current "paintFocus" property

isRolloverEnabled

public boolean isRolloverEnabled()
Returns whether or not rollover icon changes are enabled on the button.
Returns:
The state of the "rolloverEnabled" property

isSelected

public boolean isSelected()
Get the value of the button's "selected" property. Selection is only meaningful for toggle-type buttons (check boxes, radio buttons).
Returns:
The value of the property

paintBorder

protected void paintBorder(Graphics g)
Paints the button's border, if the button's "borderPainted" property is true, by out calling to the button's look and feel class.
Overrides:
paintBorder in interface JComponent
Parameters:
g - The graphics context used to paint the border

paramString

protected String paramString()
Returns a string, used only for debugging, which identifies or somehow represents this button. The exact value is implementation-defined.
Overrides:
paramString in interface JComponent
Returns:
A string representation of the button

removeActionListener

public void removeActionListener(ActionListener l)
Removes an ActionListener from the button's listener list.
Parameters:
l - The listener to remove

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the button's listener list.
Parameters:
l - The listener to remove

removeItemListener

public void removeItemListener(ItemListener l)
Removes an ItemListener from the button's listener list.
Specified by:
removeItemListener in interface ItemSelectable
Parameters:
l - The listener to remove

setAction

public void setAction(Action a)
Set the button's "action" property, subscribing the new action to the button, as an ActionListener, if it is not already subscribed. The old Action, if it exists, is unsubscribed, and the button is unsubscribed from the old Action if it was previously subscribed as a PropertyChangeListener.

This method also configures several of the button's properties from the Action, by calling configurePropertiesFromAction(Action), and subscribes the button to the Action as a PropertyChangeListener. Subsequent changes to the Action will thus reconfigure the button automatically.

Parameters:
a - The new value of the "action" property

setActionCommand

public void setActionCommand(String actionCommand)
Sets the action command string for this button's model.
Parameters:
actionCommand - The new action command string to set in the button's model.

setBorderPainted

public void setBorderPainted(boolean b)
Set the value of the "borderPainted" property. If set to false, the button's look and feel class should not paint a border for the button. The default is true.
Parameters:
b - The new value of the property.

setContentAreaFilled

public void setContentAreaFilled(boolean b)
Sets the value of the button's "contentAreaFilled" property. This property indicates whether the area surrounding the text and icon of the button should be filled by the look and feel class. If this property is false, the look and feel class should leave the content area transparent.
Parameters:
b - The new value of the "contentAreaFilled" property

setDisabledIcon

public void setDisabledIcon(Icon d)
Set the button's "disabledIcon" property. The look and feel class should paint this icon when the "enabled" property of the button's ButtonModel is false. This property may be null, in which case an icon is constructed, based on the default icon.
Parameters:
d - The new "disabledIcon" property

setDisabledSelectedIcon

public void setDisabledSelectedIcon(Icon icon)
Set the button's disabled selected icon. The look and feel class should paint this icon when the "enabled" property of the button's model is false and its "selected" property is true. This icon can be null, in which case it is synthesized from the button's selected icon.
Parameters:
icon - The new disabled selected icon

setDisplayedMnemonicIndex

public void setDisplayedMnemonicIndex(int index)
Sets the button's mnemonic index. The mnemonic index is a hint to the look and feel class, suggesting which character in the button's label should be underlined when drawing the label. If the mnemonic index is -1, no mnemonic will be displayed. If no mnemonic index is set, the button will choose a mnemonic index by default, which will be the first occurrence of the mnemonic character in the button's text.
Parameters:
index - An offset into the "text" property of the button
Throws:
IllegalArgumentException - If index is not within the range of legal offsets for the "text" property of the button.
Since:
1.4

setEnabled

public void setEnabled(boolean b)
Enables or disables the button. A button will neither be selectable nor preform any actions unless it is enabled.
Overrides:
setEnabled in interface JComponent
Parameters:
b - Whether or not to enable the button

setFocusPainted

public void setFocusPainted(boolean p)
Set the button's "paintFocus" property. This property controls whether or not the look and feel class will paint a special indicator of focus state for the button. If it is false, the button still paints when focused, but no special decoration is painted to indicate the presence of focus.
Parameters:
p - The new "paintFocus" property

setHorizontalAlignment

public void setHorizontalAlignment(int a)
Set the horizontal alignment of the button's text and icon. The alignment is a numeric constant from SwingConstants. It must be one of: RIGHT, LEFT, CENTER, LEADING or TRAILING. The default is CENTER.
Parameters:
a - The new horizontal alignment
Throws:
IllegalArgumentException - If alignment is not one of the legal constants.

setHorizontalTextPosition

public void setHorizontalTextPosition(int t)
Set the horizontal position of the button's text relative to its icon. The position is a numeric constant from SwingConstants. It must be one of: RIGHT, LEFT, CENTER, LEADING or TRAILING. The default is TRAILING.
Parameters:
t - The new horizontal text position
Throws:
IllegalArgumentException - If position is not one of the legal constants.

setIcon

public void setIcon(Icon i)
Set the button's default "icon" property. This icon is used as a basis for the pressed and disabled icons, if none are explicitly set.
Parameters:
i - The new default icon

setIconTextGap

public void setIconTextGap(int i)
Set the value of the iconTextGap property.
Parameters:
i - The new value of the property
Since:
1.4

setLabel

public void setLabel(String label)

Deprecated. use setText(text)

Set the button's "label" property. This property is synonymous with the "text" property.
Parameters:
label - The new "label" property

setLayout

public void setLayout(LayoutManager layout)
Sets a layout manager on this AbstractButton. This is overridden in order to detect if the application sets a custom layout manager. If no custom layout manager is set, addImpl(Component,Object,int) installs an OverlayLayout before adding a component.
Overrides:
setLayout in interface Container
Parameters:
layout - the layout manager to install
Since:
1.5

setMargin

public void setMargin(Insets m)
Set the button's "margin" property, which is an Insets object describing the distance between the button's border and its text and icon.
Parameters:
m - The new "margin" property

setMnemonic

public void setMnemonic(char mne)
Set the current keyboard mnemonic value. This value corresponds to a single key code (one of the KeyEvent VK_* codes) and is used to activate the button when pressed in conjunction with the "mouseless modifier" of the button's look and feel class, and when focus is in one of the button's ancestors.
Parameters:
mne - A new mnemonic to use for the button

setMnemonic

public void setMnemonic(int mne)
Set the current keyboard mnemonic value. This value corresponds to a single key code (one of the KeyEvent VK_* codes) and is used to activate the button when pressed in conjunction with the "mouseless modifier" of the button's look and feel class, and when focus is in one of the button's ancestors.
Parameters:
mne - A new mnemonic to use for the button

setModel

public void setModel(ButtonModel newModel)
Set the model the button is currently using. This un-registers all listeners associated with the current model, and re-registers them with the new model.
Parameters:
newModel - The new model

setMultiClickThreshhold

public void setMultiClickThreshhold(long threshhold)
Sets the time in milliseconds in which clicks gets coalesced into a single ActionEvent.
Parameters:
threshhold - the time in milliseconds
Since:
1.4

setPressedIcon

public void setPressedIcon(Icon pressedIcon)
Set the button's "pressedIcon" property. The look and feel class should paint this icon when the "pressed" property of the button's ButtonModel is true. This property may be null, in which case the default icon is used.
Parameters:
pressedIcon - The new "pressedIcon" property

setRolloverEnabled

public void setRolloverEnabled(boolean r)
Set the "rolloverEnabled" property. When rollover is enabled, and the look and feel supports it, the button will change its icon to rolloverIcon, when the mouse passes over it.
Parameters:
r - Whether or not to enable rollover icon changes

setRolloverIcon

public void setRolloverIcon(Icon r)
Set the button's rollover icon and sets the rolloverEnabled property to true. The look and feel class should paint this icon when the "rolloverEnabled" property of the button is true and the mouse rolls over the button.
Parameters:
r - The new rollover icon

setRolloverSelectedIcon

public void setRolloverSelectedIcon(Icon r)
Set the button's rollover selected icon and sets the rolloverEnabled property to true. The look and feel class should paint this icon when the "rolloverEnabled" property of the button is true, the "selected" property of the button's model is true, and the mouse rolls over the button.
Parameters:
r - The new rollover selected icon.

setSelected

public void setSelected(boolean s)
Set the value of the button's "selected" property. Selection is only meaningful for toggle-type buttons (check boxes, radio buttons).
Parameters:
s - New value for the property

setSelectedIcon

public void setSelectedIcon(Icon s)
Set the button's selected icon. The look and feel class should paint this icon when the "selected" property of the button's model is true, and either the "rolloverEnabled" property of the button is false or the mouse is not currently rolled over the button.
Parameters:
s - The new selected icon

setText

public void setText(String t)
Set the button's "text" property. This property is synonymous with the "label" property.
Parameters:
t - The new "text" property

setUI

public void setUI(ButtonUI ui)
Set the "UI" property of the button, which is a look and feel class responsible for handling the button's input events and painting it.
Parameters:
ui - The new "UI" property

setVerticalAlignment

public void setVerticalAlignment(int a)
Set the vertical alignment of the button's text and icon. The alignment is a numeric constant from SwingConstants. It must be one of: CENTER, TOP, or BOTTOM. The default is CENTER.
Parameters:
a - The new vertical alignment
Throws:
IllegalArgumentException - If alignment is not one of the legal constants.

setVerticalTextPosition

public void setVerticalTextPosition(int t)
Set the vertical position of the button's text relative to its icon. The alignment is a numeric constant from SwingConstants. It must be one of: CENTER, TOP, or BOTTOM. The default is CENTER.
Parameters:
t - The new vertical position
Throws:
IllegalArgumentException - If position is not one of the legal constants.

updateUI

public void updateUI()
Set the "UI" property to a class constructed, via the UIManager, from the current look and feel. This should be overridden for each subclass of AbstractButton, to retrieve a suitable ButtonUI look and feel class.
Overrides:
updateUI in interface JComponent

AbstractButton.java -- Provides basic button functionality. Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.