GNU Classpath (0.95) | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
Property | Stored in | Bound? |
---|---|---|
action | button | no |
actionCommand | model | no |
borderPainted | button | yes |
contentAreaFilled | button | yes |
disabledIcon | button | yes |
disabledSelectedIcon | button | yes |
displayedMnemonicIndex | button | no |
enabled | model | no |
focusPainted | button | yes |
horizontalAlignment | button | yes |
horizontalTextPosition | button | yes |
icon | button | yes |
iconTextGap | button | no |
label (same as text) | model | yes |
margin | button | yes |
multiClickThreshold | button | no |
pressedIcon | button | yes |
rolloverEnabled | button | yes |
rolloverIcon | button | yes |
rolloverSelectedIcon | button | yes |
selected | model | no |
selectedIcon | button | yes |
selectedObjects | button | no |
text | model | yes |
UI | button | yes |
verticalAlignment | button | yes |
verticalTextPosition | button | yes |
true
, the model will fire an ActionEvent to its
ActionListeners, which include the button. The button will propagate
this ActionEvent to its ActionListeners, with the ActionEvent's "source"
property set to refer to the button, rather than the model.Nested Class Summary | |
protected abstract class |
|
protected class |
|
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 |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
protected ActionListener |
|
protected ChangeEvent |
|
protected ChangeListener |
|
protected ItemListener |
|
protected ButtonModel |
|
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 | |
|
Method Summary | |
void |
|
void |
|
protected void | |
void |
|
protected int |
|
protected int |
|
protected void |
|
protected ActionListener |
|
protected PropertyChangeListener |
|
protected ChangeListener |
|
protected ItemListener |
|
void |
|
void |
|
protected void |
|
protected void |
|
protected void |
|
Action |
|
String |
|
ActionListener[] |
|
ChangeListener[] |
|
Icon |
|
Icon |
|
int |
|
int |
|
int |
|
Icon |
|
int |
|
ItemListener[] |
|
String |
|
Insets | |
int |
|
ButtonModel |
|
long |
|
Icon |
|
Icon |
|
Icon |
|
Icon |
|
Object[] |
|
String |
|
ButtonUI |
|
int |
|
int |
|
boolean |
|
protected void | |
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
protected void |
|
protected String |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void | |
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
void |
|
void |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final String BORDER_PAINTED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "borderPainted" property changes.
- Field Value:
- "borderPainted"
public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "contentAreaFilled" property changes.
- Field Value:
- "contentAreaFilled"
public static final String DISABLED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "disabledIcon" property changes.
- Field Value:
- "disabledIcon"
public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "disabledSelectedIcon" property changes.
- Field Value:
- "disabledSelectedIcon"
public static final String FOCUS_PAINTED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "focusPainted" property changes.
- Field Value:
- "focusPainted"
public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "horizontalAlignment" property changes.
- Field Value:
- "horizontalAlignment"
public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "horizontalTextPosition" property changes.
- Field Value:
- "horizontalTextPosition"
public static final String ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "icon" property changes.
- Field Value:
- "icon"
public static final String MARGIN_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "margin" property changes.
- Field Value:
- "margin"
public static final String MNEMONIC_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "mnemonic" property changes.
- Field Value:
- "mnemonic"
public static final String MODEL_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "model" property changes.
- Field Value:
- "model"
public static final String PRESSED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "pressedIcon" property changes.
- Field Value:
- "pressedIcon"
public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverEnabled" property changes.
- Field Value:
- "rolloverEnabled"
public static final String ROLLOVER_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverIcon" property changes.
- Field Value:
- "rolloverIcon"
public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "rolloverSelectedIcon" property changes.
- Field Value:
- "rolloverSelectedIcon"
public static final String SELECTED_ICON_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "selectedIcon" property changes.
- Field Value:
- "selectedIcon"
public static final String TEXT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "text" property changes.
- Field Value:
- "text"
public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "verticalAlignment" property changes.
- Field Value:
- "verticalAlignment"
public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Fired in a PropertyChangeEvent when the "verticalTextPosition" property changes.
- Field Value:
- "verticalTextPosition"
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.
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);Theinit(String,Icon)
method is not called automatically by this constructor.
- See Also:
init(String,Icon)
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
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
protected void addImpl(Component comp, Object constraints, int index)
Adds the specified component to this AbstractButton. This overrides the default in order to install anOverlayLayout
layout manager before adding the component. The layout manager is only installed if no other layout manager has been installed before.
- Parameters:
comp
- the component to be addedconstraints
- constraints for the layout managerindex
- the index at which the component is added
- Since:
- 1.5
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
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 ofSwingConstants
:RIGHT
,LEFT
,CENTER
,LEADING
orTRAILING
.
- Parameters:
key
- The key to checkexception
- A message to include in an IllegalArgumentException
- Returns:
- the value of key
- Throws:
IllegalArgumentException
- If key is not one of the valid constants
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 ofSwingConstants
:TOP
,BOTTOM
orCENTER
.
- Parameters:
key
- The key to checkexception
- A message to include in an IllegalArgumentException
- Returns:
- the value of key
- Throws:
IllegalArgumentException
- If key is not one of the valid constants
protected void configurePropertiesFromAction(Action a)
Configure various properties of the button by reading properties of anAction
. The mapping of properties is as follows: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
Action keyed property AbstractButton property NAME text SMALL_ICON icon SHORT_DESCRIPTION toolTipText MNEMONIC_KEY mnemonic ACTION_COMMAND_KEY actionCommand null
, the text, icon, and toolTipText properties of the button are set tonull
, and the "enabled" property is set totrue
; the mnemonic and actionCommand properties are unchanged.
- Parameters:
a
- An Action to configure the button from
protected ActionListener createActionListener()
A factory method which should return anActionListener
that propagates events from the button'sButtonModel
to any of the button's ActionListeners. By default, this is an inner class which callsfireActionPerformed(ActionEvent)
with a modified copy of the incoming modelActionEvent
. The button calls this method during construction, stores the resulting ActionListener in itsactionListener
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
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
A factory method which should return aPropertyChangeListener
that accepts changes to the specifiedAction
and reconfigure theAbstractButton
, by default using theconfigurePropertiesFromAction(Action)
method. The button calls this method whenever a new Action is assigned to the button's "action" property, viasetAction(Action)
, and stores the resulting PropertyChangeListener in itsactionPropertyChangeListener
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
protected ChangeListener createChangeListener()
Factory method which creates aChangeListener
, 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 theChangeEvent
to the button's ChangeListeners, via thefireStateChanged()
method. The button calls this method during construction, stores the resulting ChangeListener in itschangeListener
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
protected ItemListener createItemListener()
Factory method which creates aItemListener
, 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 theItemEvent
to the button's ItemListeners, via thefireItemStateChanged(ItemEvent)
method. The button calls this method during construction, stores the resulting ItemListener in itschangeListener
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
public void doClick()
Programmatically perform a "click" on the button: arming, pressing, waiting, un-pressing, and disarming the model.
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
protected void fireActionPerformed(ActionEvent e)
CallsActionListener.actionPerformed(ActionEvent)
on eachActionListener
in the button's listener list.
- Parameters:
e
- The event signifying that the button's model was clicked
protected void fireItemStateChanged(ItemEvent e)
CallsItemListener.itemStateChanged(ItemEvent)
on each ItemListener in the button's listener list.
- Parameters:
e
- The event signifying that the button's model changed state
protected void fireStateChanged()
CallsChangeListener.stateChanged(ChangeEvent)
on eachChangeListener
in the button's listener list.
public Action getAction()
Get the value of the "action" property.
- Returns:
- The current value of the "action" property
public String getActionCommand()
Returns the action command string for this button's model. If the action command was set tonull
, the button's text (label) is returned instead.
- Returns:
- The current action command string from the button's model
public ActionListener[] getActionListeners()
Returns all addedActionListener
objects.
- Returns:
- an array of listeners
- Since:
- 1.4
public ChangeListener[] getChangeListeners()
Returns all addedChangeListener
objects.
- Returns:
- an array of listeners
- Since:
- 1.4
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'sButtonModel
isfalse
. This property may benull
, in which case an icon is constructed, based on the default icon.
- Returns:
- The current "disabledIcon" property
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 isfalse
and its "selected" property istrue
. This icon can benull
, in which case it is synthesized from the button's selected icon.
- Returns:
- The current disabled selected icon
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
public int getHorizontalAlignment()
Set the horizontal alignment of the button's text and icon. The alignment is a numeric constant fromSwingConstants
. It must be one of:RIGHT
,LEFT
,CENTER
,LEADING
orTRAILING
. The default isCENTER
.
- Returns:
- The current horizontal alignment
- See Also:
setHorizontalAlignment(int)
public int getHorizontalTextPosition()
Get the horizontal position of the button's text relative to its icon. The position is a numeric constant fromSwingConstants
. It must be one of:RIGHT
,LEFT
,CENTER
,LEADING
orTRAILING
. The default isTRAILING
.
- Returns:
- The current horizontal text position
public Icon getIcon()
Return the button's default "icon" property.
- Returns:
- The current default icon
public int getIconTextGap()
Get the value of theiconTextGap
property.
- Returns:
- The current value of the property
- Since:
- 1.4
public ItemListener[] getItemListeners()
Returns all addedItemListener
objects.
- Returns:
- an array of listeners
- Since:
- 1.4
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
public Insets getMargin()
Return the button's "margin" property, which is anInsets
object describing the distance between the button's border and its text and icon.
- Returns:
- The current "margin" property
public int getMnemonic()
Get the current keyboard mnemonic value. This value corresponds to a single key code (one of theKeyEvent
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
public ButtonModel getModel()
Get the model the button is currently using.
- Returns:
- The current model
public long getMultiClickThreshhold()
Returns the current time in milliseconds in which clicks gets coalesced into a singleActionEvent
.
- Returns:
- the time in milliseconds
- Since:
- 1.4
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'sButtonModel
istrue
. This property may benull
, in which case the default icon is used.
- Returns:
- The current "pressedIcon" property
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 istrue
and the mouse rolls over the button.
- Returns:
- The current rollover icon
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 istrue
, the "selected" property of the button's model istrue
, and the mouse rolls over the button.
- Returns:
- The current rollover selected icon
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 istrue
, and either the "rolloverEnabled" property of the button isfalse
or the mouse is not currently rolled over the button.
- Returns:
- The current selected icon
public Object[] getSelectedObjects()
Returns an single-element array containing the "text" property of the button if the "selected" property of the button's model istrue
, otherwise returnsnull
.
- Specified by:
- getSelectedObjects in interface ItemSelectable
- Returns:
- The button's "selected object" array
public String getText()
Return the button's "text" property. This property is synonymous with the "label" property.
- Returns:
- The current "text" property
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
public int getVerticalAlignment()
Get the vertical alignment of the button's text and icon. The alignment is a numeric constant fromSwingConstants
. It must be one of:CENTER
,TOP
, orBOTTOM
. The default isCENTER
.
- Returns:
- The current vertical alignment
- See Also:
setVerticalAlignment(int)
public int getVerticalTextPosition()
Get the vertical position of the button's text relative to its icon. The alignment is a numeric constant fromSwingConstants
. It must be one of:CENTER
,TOP
, orBOTTOM
. The default isCENTER
.
- Returns:
- The current vertical position
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 updatedinfoflags
- One of the constant codes inImageObserver
used to describe updated portions of an image.x
- X coordinate of the region being updatedy
- Y coordinate of the region being updatedw
- Width of the region beign updatedh
- Height of the region being updated
- Returns:
true
if img is equal to the button's current icon, otherwisefalse
public boolean isBorderPainted()
Set the value of the "borderPainted" property. If set tofalse
, the button's look and feel class should not paint a border for the button. The default istrue
.
- Returns:
- The current value of the property.
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 isfalse
, the look and feel class should leave the content area transparent.
- Returns:
- The current value of the "contentAreaFilled" property
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
public boolean isRolloverEnabled()
Returns whether or not rollover icon changes are enabled on the button.
- Returns:
- The state of the "rolloverEnabled" property
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
protected void paintBorder(Graphics g)
Paints the button's border, if the button's "borderPainted" property istrue
, 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
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
public void removeActionListener(ActionListener l)
Removes an ActionListener from the button's listener list.
- Parameters:
l
- The listener to remove
public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the button's listener list.
- Parameters:
l
- The listener to remove
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
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 callingconfigurePropertiesFromAction(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
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.
public void setBorderPainted(boolean b)
Set the value of the "borderPainted" property. If set tofalse
, the button's look and feel class should not paint a border for the button. The default istrue
.
- Parameters:
b
- The new value of the property.
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 isfalse
, the look and feel class should leave the content area transparent.
- Parameters:
b
- The new value of the "contentAreaFilled" property
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'sButtonModel
isfalse
. This property may benull
, in which case an icon is constructed, based on the default icon.
- Parameters:
d
- The new "disabledIcon" property
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 isfalse
and its "selected" property istrue
. This icon can benull
, in which case it is synthesized from the button's selected icon.
- Parameters:
icon
- The new disabled selected icon
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
- Ifindex
is not within the range of legal offsets for the "text" property of the button.
- Since:
- 1.4
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
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
public void setHorizontalAlignment(int a)
Set the horizontal alignment of the button's text and icon. The alignment is a numeric constant fromSwingConstants
. It must be one of:RIGHT
,LEFT
,CENTER
,LEADING
orTRAILING
. The default isCENTER
.
- Parameters:
a
- The new horizontal alignment
- Throws:
IllegalArgumentException
- If alignment is not one of the legal constants.
- See Also:
getHorizontalAlignment()
public void setHorizontalTextPosition(int t)
Set the horizontal position of the button's text relative to its icon. The position is a numeric constant fromSwingConstants
. It must be one of:RIGHT
,LEFT
,CENTER
,LEADING
orTRAILING
. The default isTRAILING
.
- Parameters:
t
- The new horizontal text position
- Throws:
IllegalArgumentException
- If position is not one of the legal constants.
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
public void setIconTextGap(int i)
Set the value of theiconTextGap
property.
- Parameters:
i
- The new value of the property
- Since:
- 1.4
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
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.
- Parameters:
layout
- the layout manager to install
- Since:
- 1.5
public void setMargin(Insets m)
Set the button's "margin" property, which is anInsets
object describing the distance between the button's border and its text and icon.
- Parameters:
m
- The new "margin" property
public void setMnemonic(char mne)
Set the current keyboard mnemonic value. This value corresponds to a single key code (one of theKeyEvent
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
public void setMnemonic(int mne)
Set the current keyboard mnemonic value. This value corresponds to a single key code (one of theKeyEvent
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
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
public void setMultiClickThreshhold(long threshhold)
Sets the time in milliseconds in which clicks gets coalesced into a singleActionEvent
.
- Parameters:
threshhold
- the time in milliseconds
- Since:
- 1.4
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'sButtonModel
istrue
. This property may benull
, in which case the default icon is used.
- Parameters:
pressedIcon
- The new "pressedIcon" property
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
public void setRolloverIcon(Icon r)
Set the button's rollover icon and sets therolloverEnabled
property totrue
. The look and feel class should paint this icon when the "rolloverEnabled" property of the button istrue
and the mouse rolls over the button.
- Parameters:
r
- The new rollover icon
public void setRolloverSelectedIcon(Icon r)
Set the button's rollover selected icon and sets therolloverEnabled
property totrue
. The look and feel class should paint this icon when the "rolloverEnabled" property of the button istrue
, the "selected" property of the button's model istrue
, and the mouse rolls over the button.
- Parameters:
r
- The new rollover selected icon.
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
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 istrue
, and either the "rolloverEnabled" property of the button isfalse
or the mouse is not currently rolled over the button.
- Parameters:
s
- The new selected icon
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
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
public void setVerticalAlignment(int a)
Set the vertical alignment of the button's text and icon. The alignment is a numeric constant fromSwingConstants
. It must be one of:CENTER
,TOP
, orBOTTOM
. The default isCENTER
.
- Parameters:
a
- The new vertical alignment
- Throws:
IllegalArgumentException
- If alignment is not one of the legal constants.
- See Also:
getVerticalAlignment()
public void setVerticalTextPosition(int t)
Set the vertical position of the button's text relative to its icon. The alignment is a numeric constant fromSwingConstants
. It must be one of:CENTER
,TOP
, orBOTTOM
. The default isCENTER
.
- Parameters:
t
- The new vertical position
- Throws:
IllegalArgumentException
- If position is not one of the legal constants.
public void updateUI()
Set the "UI" property to a class constructed, via theUIManager
, from the current look and feel. This should be overridden for each subclass of AbstractButton, to retrieve a suitableButtonUI
look and feel class.
- Overrides:
- updateUI in interface JComponent
GNU Classpath (0.95) |