|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.AbstractButton
Defines the common behaviors for the JButton, JToggleButton, JCheckbox, and the JRadioButton classes.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Inner Class Summary | |
protected class |
AbstractButton.AccessibleAbstractButton
Accessiblity support. |
protected class |
AbstractButton.ButtonChangeListener
Extend ChangeListener to be serializable |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Field Summary | |
protected ActionListener |
actionListener
|
static String |
BORDER_PAINTED_CHANGED_PROPERTY
Identifies a change to having the border drawn, or having it not drawn. |
protected ChangeEvent |
changeEvent
Only one ChangeEvent is needed per button instance since the event's only state is the source property. |
protected ChangeListener |
changeListener
The button's model listeners. |
static String |
CONTENT_AREA_FILLED_CHANGED_PROPERTY
Identifies a change from rollover enabled to disabled or back to enabled. |
static String |
DISABLED_ICON_CHANGED_PROPERTY
Identifies a change to the icon used when the button has been disabled. |
static String |
DISABLED_SELECTED_ICON_CHANGED_PROPERTY
Identifies a change to the icon used when the button has been disabled and selected. |
static String |
FOCUS_PAINTED_CHANGED_PROPERTY
Identifies a change to having the border highlighted when focused, or not. |
static String |
HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
Identifies a change in the button's horizontal alignment. |
static String |
HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
Identifies a change in the button's horizontal text position. |
static String |
ICON_CHANGED_PROPERTY
Identifies a change to the icon that represents the button. |
protected ItemListener |
itemListener
|
static String |
MARGIN_CHANGED_PROPERTY
Identifies a change in the button's margins. |
static String |
MNEMONIC_CHANGED_PROPERTY
Identifies a change to the button's mnemonic. |
protected ButtonModel |
model
The data model that determines the button's state. |
static String |
MODEL_CHANGED_PROPERTY
Identifies a change in the button model. |
static String |
PRESSED_ICON_CHANGED_PROPERTY
Identifies a change to the icon used when the button has been pressed. |
static String |
ROLLOVER_ENABLED_CHANGED_PROPERTY
Identifies a change in the button's |
static String |
ROLLOVER_ICON_CHANGED_PROPERTY
Identifies a change to the icon used when the cursor is over the button. |
static String |
ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
Identifies a change to the icon used when the cursror is over the button and it has been selected. |
static String |
SELECTED_ICON_CHANGED_PROPERTY
Identifies a change to the icon used when the button has been selected. |
static String |
TEXT_CHANGED_PROPERTY
Identifies a change in the button's text. |
static String |
VERTICAL_ALIGNMENT_CHANGED_PROPERTY
Identifies a change in the button's vertical alignment. |
static String |
VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
Identifies a change in the button's vertical text position. |
Fields inherited from class javax.swing.JComponent |
accessibleContext,
listenerList,
TOOL_TIP_TEXT_KEY,
ui,
UNDEFINED_CONDITION,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
WHEN_FOCUSED,
WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM,
CENTER,
EAST,
HORIZONTAL,
LEADING,
LEFT,
NORTH,
NORTH_EAST,
NORTH_WEST,
RIGHT,
SOUTH,
SOUTH_EAST,
SOUTH_WEST,
TOP,
TRAILING,
VERTICAL,
WEST |
Constructor Summary | |
AbstractButton()
|
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 an ItemListener to the checkbox |
protected int |
checkHorizontalKey(int key,
String exception)
Verify that key is a legal value for the horizontalAlignment properties. |
protected int |
checkVerticalKey(int key,
String exception)
Ensures that the key is a valid. |
protected ActionListener |
createActionListener()
|
protected ChangeListener |
createChangeListener()
Subclasses that want to handle ChangeEvents differently can override this to return another ChangeListener implementation. |
protected ItemListener |
createItemListener()
|
void |
doClick()
Programatically perform a "click". |
void |
doClick(int pressTime)
Programatically perform a "click". |
protected void |
fireActionPerformed(ActionEvent event)
|
protected void |
fireItemStateChanged(ItemEvent event)
|
protected void |
fireStateChanged()
|
String |
getActionCommand()
Returns the action command for this button. |
Icon |
getDisabledIcon()
Returns the icon used by the button when it's disabled. |
Icon |
getDisabledSelectedIcon()
Returns the icon used by the button when it's disabled and selected. |
int |
getHorizontalAlignment()
Returns the horizontal alignment of the icon and text. |
int |
getHorizontalTextPosition()
Sets the horizontal position of the text relative to the icon. |
Icon |
getIcon()
Returns the default icon. |
String |
getLabel()
Deprecated. - Replaced by getText() |
Insets |
getMargin()
Returns the margin between the button's border and the label. |
int |
getMnemonic()
Get the keyboard mnemonic from the the current model |
ButtonModel |
getModel()
Get the model that this button represents. |
Icon |
getPressedIcon()
Returns the pressed icon for the button. |
Icon |
getRolloverIcon()
Returns the rollover icon for the button. |
Icon |
getRolloverSelectedIcon()
Returns the rollover seletion icon for the button. |
Icon |
getSelectedIcon()
Returns the selected icon for the button. |
Object[] |
getSelectedObjects()
Returns an array (length 1) containing the label or null if the button is not selected. |
String |
getText()
Returns the button's text. |
ButtonUI |
getUI()
Returns the button's current UI. |
int |
getVerticalAlignment()
Returns the vertical alignment of the text and icon. |
int |
getVerticalTextPosition()
Returns the vertical position of the text relative to the icon Valid keys: CENTER (the default), TOP, BOTTOM |
protected void |
init(String text,
Icon icon)
|
boolean |
isBorderPainted()
Returns whether the border should be painted. |
boolean |
isContentAreaFilled()
Checks whether the "content area" of the button should be filled. |
boolean |
isFocusPainted()
Returns whether focus should be painted. |
boolean |
isRolloverEnabled()
Checks whether rollover effects are enabled. |
boolean |
isSelected()
Returns the state of the button. |
protected void |
paintBorder(Graphics g)
Paint the button's border if BorderPainted property is true. |
protected String |
paramString()
Returns a string representation of this AbstractButton. |
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 an ItemListener from the button |
void |
setActionCommand(String actionCommand)
Sets the action command for this button. |
void |
setBorderPainted(boolean b)
Sets whether the border should be painted. |
void |
setContentAreaFilled(boolean b)
Sets whether the button should paint the content area or leave it transparent. |
void |
setDisabledIcon(Icon disabledIcon)
Sets the disabled icon for the button. |
void |
setDisabledSelectedIcon(Icon disabledSelectedIcon)
Sets the disabled selection icon for the button. |
void |
setEnabled(boolean b)
Enables (or disables) the button. |
void |
setFocusPainted(boolean b)
Sets whether focus should be painted. |
void |
setHorizontalAlignment(int alignment)
Sets the horizontal alignment of the icon and text. |
void |
setHorizontalTextPosition(int textPosition)
Sets the horizontal position of the text relative to the icon. |
void |
setIcon(Icon defaultIcon)
Sets the button's default icon. |
void |
setLabel(String label)
Deprecated. - Replaced by setText(text) |
void |
setMargin(Insets m)
Sets space for margin between the button's border and the label. |
void |
setMnemonic(char mnemonic)
Specifies the mnemonic value. |
void |
setMnemonic(int mnemonic)
Set the keyboard mnemonic on the current model. |
void |
setModel(ButtonModel newModel)
Set the model that this button represents. |
void |
setPressedIcon(Icon pressedIcon)
Sets the pressed icon for the button. |
void |
setRolloverEnabled(boolean b)
Sets whether rollover effects should be enabled. |
void |
setRolloverIcon(Icon rolloverIcon)
Sets the rollover icon for the button. |
void |
setRolloverSelectedIcon(Icon rolloverSelectedIcon)
Sets the rollover selected icon for the button. |
void |
setSelected(boolean b)
Sets the state of the button. |
void |
setSelectedIcon(Icon selectedIcon)
Sets the selected icon for the button. |
void |
setText(String text)
Sets the button's text. |
void |
setUI(ButtonUI ui)
Sets the button's UI. |
void |
setVerticalAlignment(int alignment)
Sets the vertical alignment of the icon and text. |
void |
setVerticalTextPosition(int textPosition)
Sets the vertical position of the text relative to the icon. |
void |
updateUI()
Gets a new UI object from the default UIFactory. |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
remove,
remove,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final String MODEL_CHANGED_PROPERTY
public static final String TEXT_CHANGED_PROPERTY
public static final String MNEMONIC_CHANGED_PROPERTY
public static final String MARGIN_CHANGED_PROPERTY
public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
public static final String BORDER_PAINTED_CHANGED_PROPERTY
public static final String FOCUS_PAINTED_CHANGED_PROPERTY
public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY
public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY
public static final String ICON_CHANGED_PROPERTY
public static final String PRESSED_ICON_CHANGED_PROPERTY
public static final String SELECTED_ICON_CHANGED_PROPERTY
public static final String ROLLOVER_ICON_CHANGED_PROPERTY
public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
public static final String DISABLED_ICON_CHANGED_PROPERTY
public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY
protected ButtonModel model
protected ChangeListener changeListener
protected ActionListener actionListener
protected ItemListener itemListener
protected transient ChangeEvent changeEvent
Constructor Detail |
public AbstractButton()
Method Detail |
public String getText()
setText(java.lang.String)
public void setText(String text)
t
- the string used to set the textgetText()
public boolean isSelected()
public void setSelected(boolean b)
public void doClick()
public void doClick(int pressTime)
public void setMargin(Insets m)
m
- the space between the border and the labelpublic Insets getMargin()
setMargin(java.awt.Insets)
public Icon getIcon()
setIcon(javax.swing.Icon)
public void setIcon(Icon defaultIcon)
g
- the icon used as the default imagegetIcon()
,
setPressedIcon(javax.swing.Icon)
public Icon getPressedIcon()
setPressedIcon(javax.swing.Icon)
public void setPressedIcon(Icon pressedIcon)
g
- the icon used as the "pressed" imagegetPressedIcon()
public Icon getSelectedIcon()
setSelectedIcon(javax.swing.Icon)
public void setSelectedIcon(Icon selectedIcon)
g
- the icon used as the "selected" imagegetSelectedIcon()
public Icon getRolloverIcon()
setRolloverIcon(javax.swing.Icon)
public void setRolloverIcon(Icon rolloverIcon)
g
- the icon used as the "rollover" imagegetRolloverIcon()
public Icon getRolloverSelectedIcon()
setRolloverSelectedIcon(javax.swing.Icon)
public void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
g
- the icon used as the "selected rollover" imagegetRolloverSelectedIcon()
public Icon getDisabledIcon()
getPressedIcon()
,
setDisabledIcon(javax.swing.Icon)
public void setDisabledIcon(Icon disabledIcon)
g
- the icon used as the disabled imagegetDisabledIcon()
public Icon getDisabledSelectedIcon()
getPressedIcon()
,
setDisabledIcon(javax.swing.Icon)
public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
g
- the icon used as the disabled selection imagegetDisabledSelectedIcon()
public int getVerticalAlignment()
public void setVerticalAlignment(int alignment)
public int getHorizontalAlignment()
public void setHorizontalAlignment(int alignment)
public int getVerticalTextPosition()
public void setVerticalTextPosition(int textPosition)
public int getHorizontalTextPosition()
public void setHorizontalTextPosition(int textPosition)
protected int checkHorizontalKey(int key, String exception)
key
- the property value to checkexception
- the IllegalArgumentException detail messagesetHorizontalTextPosition(int)
,
setHorizontalAlignment(int)
protected int checkVerticalKey(int key, String exception)
public void setActionCommand(String actionCommand)
public String getActionCommand()
public boolean isBorderPainted()
setBorderPainted(boolean)
public void setBorderPainted(boolean b)
b
- if true and border property is not null, the border is painted.isBorderPainted()
protected void paintBorder(Graphics g)
JComponent.paint(java.awt.Graphics)
,
JComponent.setBorder(javax.swing.border.Border)
public boolean isFocusPainted()
setFocusPainted(boolean)
public void setFocusPainted(boolean b)
b
- if true, the focus state is painted.isFocusPainted()
public boolean isContentAreaFilled()
setFocusPainted(boolean)
public void setContentAreaFilled(boolean b)
b
- if true, rollover effects should be painted.isContentAreaFilled()
,
JComponent.setOpaque(boolean)
public boolean isRolloverEnabled()
setFocusPainted(boolean)
public void setRolloverEnabled(boolean b)
b
- if true, rollover effects should be painted.isRolloverEnabled()
public int getMnemonic()
public void setMnemonic(int mnemonic)
mnemonic
- the key code which represents the mnemonicpublic void setMnemonic(char mnemonic)
mnemonic
- a char specifying the mnemonic valuepublic ButtonModel getModel()
setModel(javax.swing.ButtonModel)
public void setModel(ButtonModel newModel)
m
- the ModelgetModel()
public ButtonUI getUI()
setUI(javax.swing.plaf.ButtonUI)
public void setUI(ButtonUI ui)
ui
- the new ButtonUIgetUI()
public void updateUI()
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
UIManager.getLookAndFeel()
,
UIManager.getUI(javax.swing.JComponent)
public void addChangeListener(ChangeListener l)
public void removeChangeListener(ChangeListener l)
protected void fireStateChanged()
public void addActionListener(ActionListener l)
public void removeActionListener(ActionListener l)
protected ChangeListener createChangeListener()
protected void fireActionPerformed(ActionEvent event)
protected void fireItemStateChanged(ItemEvent event)
protected ActionListener createActionListener()
protected ItemListener createItemListener()
public void setEnabled(boolean b)
Component.isEnabled()
public String getLabel()
public void setLabel(String label)
label
- a String containing the textpublic void addItemListener(ItemListener l)
l
- the listener to recieve eventsItemEvent
public void removeItemListener(ItemListener l)
l
- the listener being removedItemEvent
public Object[] getSelectedObjects()
protected void init(String text, Icon icon)
protected String paramString()
null
.
Overriding paramString() to provide information about the specific new aspects of the JFC components.
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |