All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.AbstractButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.AbstractButton

public abstract class AbstractButton
extends JComponent
implements ItemSelectable, SwingConstants

Variable Index

 o actionListener
 o actionListenerList
 o border
 o changeEvent
Only one ChangeEvent is needed per button instance since the event's only state is the source property.
 o changeListener
The button's model listeners.
 o changeListenerList
The lists of client listeners.
 o itemListener
 o itemListenerList
 o model

Constructor Index

 o AbstractButton()

Method Index

 o addActionListener(ActionListener)
adds an ActionListener to the button
 o addChangeListener(ChangeListener)
Adds a ChangeListener to the button.
 o addItemListener(ItemListener)
adds an ItemListener to the checkbox
 o checkHorizontalKey(int, String)
Ensures that the key is a valid.
 o checkVerticalKey(int, String)
Ensures that the key is a valid.
 o createActionListener()
 o createChangeListener()
 o createItemListener()
 o doClick()
Programatically perform a "click".
 o getActionCommand()
Returns the action command for this button.
 o getAlignmentX()
Set the default horizontal alignment left
 o getBorder()
 o getDisabledIcon()
Returns the icon used by the button when it's disabled.
 o getHorizontalAlignment()
Returns the horizontal alignment of the icon and text.
 o getHorizontalTextPosition()
Sets the horizontal position of the text relative to the icon.
 o getIcon()
Returns the default icon.
 o getKeyAccelerator()
Convenience to get the accelerator from the the current model
 o getLabel()
Deprecated.
 o getMaximumSize()
PENDING(jeff): see above
 o getMaxSizeEqualsPrefSize()
PENDING(jeff): see above
 o getModel()
Get the model that this button represents.
 o getPad()
Returns a pad amount between the button's border and the label.
 o getPressedIcon()
Returns the pressed icon for the button.
 o getRolloverIcon()
Returns the rollover icon for the button.
 o getSelectedIcon()
Returns the selected icon for the button.
 o getSelectedObjects()
 o getText()
Returns the button's text.
 o getUI()
Returns the button's current UI.
 o getVerticalAlignment()
Returns the vertical alignment of the text and icon.
 o getVerticalTextPosition()
Returns the vertical position of the text relative to the icon Valid keys: CENTER (the default), TOP, BOTTOM
 o init(String, Icon)
 o isBorderPainted()
Checks whether the border should be painted.
 o isFocusPainted()
Checks whether focus should be painted.
 o isOpaque()
 o isSelected()
Returns the state of the button.
 o removeActionListener(ActionListener)
removes an ActionListener from the button
 o removeChangeListener(ChangeListener)
Removes a ChangeListener from the button.
 o removeItemListener(ItemListener)
removes an ItemListener from the button
 o setActionCommand(String)
Sets the action command for this button.
 o setBorder(Border)
 o setBorderPainted(boolean)
Sets whether the border should be painted.
 o setDisabledIcon(Icon)
Sets the disabled icon for the button.
 o setEnabled(boolean)
Enables (or disables) the button.
 o setFocusPainted(boolean)
Sets whether focus should be painted.
 o setHorizontalAlignment(int)
Sets the horizontal alignment of the icon and text.
 o setHorizontalTextPosition(int)
Sets the horizontal position of the text relative to the icon.
 o setIcon(Icon)
Sets the button's default icon.
 o setKeyAccelerator(char)
Convenience to set the key accelerator on the current model
 o setLabel(String)
Deprecated.
 o setMaxSizeEqualsPrefSize(boolean)
PENDING(jeff): This is a hack to set getMaximumSize to to Short.MAX_VALUE.
 o setModel(ButtonModel)
Set the model that this button represents.
 o setPad(Insets)
Sets a pad amount between the button's border and the label.
 o setPressedIcon(Icon)
Sets the pressed icon for the button.
 o setRolloverIcon(Icon)
Sets the rollover icon for the button.
 o setSelected(boolean)
Sets the state of the button.
 o setSelectedIcon(Icon)
Sets the selected icon for the button.
 o setText(String)
Sets the button's text.
 o setUI(ButtonUI)
Sets the button's UI.
 o setVerticalAlignment(int)
Sets the vertical alignment of the icon and text.
 o setVerticalTextPosition(int)
Sets the vertical position of the text relative to the icon.
 o updateUI()
Gets a new UI object from the default UIFactory.

Variables

 o model
 protected ButtonModel model
 o border
 protected Border border
 o changeListener
 protected ChangeListener changeListener
The button's model listeners.

 o actionListener
 protected ActionListener actionListener
 o itemListener
 protected ItemListener itemListener
 o changeListenerList
 protected ChangeListener changeListenerList
The lists of client listeners.

 o actionListenerList
 protected ActionListener actionListenerList
 o itemListenerList
 protected ItemListener itemListenerList
 o changeEvent
 protected ChangeEvent changeEvent
Only one ChangeEvent is needed per button instance since the event's only state is the source property. The source of events generated is always "this".

Constructors

 o AbstractButton
 public AbstractButton()

Methods

 o getText
 public String getText()
Returns the button's text.

See Also:
setText
 o setText
 public void setText(String t)
Sets the button's text.

Parameters:
t - the string used to set the text
See Also:
getText
 o isSelected
 public boolean isSelected()
Returns the state of the button. True if the radiobutton is selected, false if it's not.

 o setSelected
 public void setSelected(boolean b)
Sets the state of the button.

 o doClick
 public void doClick()
Programatically perform a "click". This does the same thing as if the user had pressed and released the button.

 o setMaxSizeEqualsPrefSize
 public void setMaxSizeEqualsPrefSize(boolean b)
PENDING(jeff): This is a hack to set getMaximumSize to to Short.MAX_VALUE. The current getMaximumSize is hacked to return preferredSize, which is wrong. REMIND: get rid of this once Tim's BoxLayout penalty system is in place.

Parameters:
b - - true turns on the hack (maxSize == prefSize) - false turns off the hack (maxSize == Short.MAX_VALUE)
 o getMaxSizeEqualsPrefSize
 public boolean getMaxSizeEqualsPrefSize()
PENDING(jeff): see above

See Also:
setMaxSizeEqualsPrefSize
 o getMaximumSize
 public Dimension getMaximumSize()
PENDING(jeff): see above

Overrides:
getMaximumSize in class JComponent
See Also:
setMaxSizeEqualsPrefSize
 o setPad
 public void setPad(Insets pad)
Sets a pad amount between the button's border and the label. Setting to null will cause the button to use the default padding.

 o getPad
 public Insets getPad()
Returns a pad amount between the button's border and the label.

 o getIcon
 public Icon getIcon()
Returns the default icon.

See Also:
setIcon
 o setIcon
 public void setIcon(Icon g)
Sets the button's default icon. This icon is also used as the "pressed" and "disabled" icon if there is no explicitly set pressed icon.

Parameters:
g - the icon used as the default image
See Also:
getIcon, setPressedIcon
 o getPressedIcon
 public Icon getPressedIcon()
Returns the pressed icon for the button.

See Also:
setPressedIcon
 o setPressedIcon
 public void setPressedIcon(Icon g)
Sets the pressed icon for the button.

Parameters:
g - the icon used as the "pressed" image
See Also:
getPressedIcon
 o getSelectedIcon
 public Icon getSelectedIcon()
Returns the selected icon for the button.

See Also:
setSelectedIcon
 o setSelectedIcon
 public void setSelectedIcon(Icon g)
Sets the selected icon for the button.

Parameters:
g - the icon used as the "selected" image
See Also:
getSelectedIcon
 o getRolloverIcon
 public Icon getRolloverIcon()
Returns the rollover icon for the button.

See Also:
setRolloverIcon
 o setRolloverIcon
 public void setRolloverIcon(Icon g)
Sets the rollover icon for the button.

Parameters:
g - the icon used as the "rollover" image
See Also:
getRolloverIcon
 o getDisabledIcon
 public Icon getDisabledIcon()
Returns the icon used by the button when it's disabled. If not no disabled icon has been set, the button constructs one from the default icon. REMIND: the disabled icon really should be created (if necesary) by the L&F.

See Also:
getPressedIcon, setDisabledIcon
 o setDisabledIcon
 public void setDisabledIcon(Icon g)
Sets the disabled icon for the button.

Parameters:
g - the icon used as the disabled image
See Also:
getDisabledIcon
 o getVerticalAlignment
 public int getVerticalAlignment()
Returns the vertical alignment of the text and icon. Valid keys: CENTER (the default), TOP, BOTTOM

 o setVerticalAlignment
 public void setVerticalAlignment(int x)
Sets the vertical alignment of the icon and text. Valid keys: CENTER (the default), TOP, BOTTOM

 o getHorizontalAlignment
 public int getHorizontalAlignment()
Returns the horizontal alignment of the icon and text. Valid keys: CENTER (the default), LEFT, RIGHT

 o setHorizontalAlignment
 public void setHorizontalAlignment(int x)
Sets the horizontal alignment of the icon and text. Valid keys: CENTER (the default), LEFT, RIGHT

 o getVerticalTextPosition
 public int getVerticalTextPosition()
Returns the vertical position of the text relative to the icon Valid keys: CENTER (the default), TOP, BOTTOM

 o setVerticalTextPosition
 public void setVerticalTextPosition(int x)
Sets the vertical position of the text relative to the icon. Valid keys: CENTER (the default), TOP, BOTTOM

 o getHorizontalTextPosition
 public int getHorizontalTextPosition()
Sets the horizontal position of the text relative to the icon. Valid keys: RIGHT (the default), LEFT, CENTER

 o setHorizontalTextPosition
 public void setHorizontalTextPosition(int x)
Sets the horizontal position of the text relative to the icon. Valid keys: RIGHT (the default), LEFT, CENTER

 o checkHorizontalKey
 protected int checkHorizontalKey(int key,
                                  String exception)
Ensures that the key is a valid. Throws an IllegalArgument exception exception otherwise.

 o checkVerticalKey
 protected int checkVerticalKey(int key,
                                String exception)
Ensures that the key is a valid. Throws an IllegalArgument exception exception otherwise.

 o setActionCommand
 public void setActionCommand(String actionCommand)
Sets the action command for this button.

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

 o isBorderPainted
 public boolean isBorderPainted()
Checks whether the border should be painted.

See Also:
setBorderPainted
 o isOpaque
 public boolean isOpaque()
Overrides:
isOpaque in class JComponent
 o setBorderPainted
 public void setBorderPainted(boolean b)
Sets whether the border should be painted.

Parameters:
b - if true, the border is painted.
See Also:
isBorderPainted
 o isFocusPainted
 public boolean isFocusPainted()
Checks whether focus should be painted.

See Also:
setFocusPainted
 o setFocusPainted
 public void setFocusPainted(boolean b)
Sets whether focus should be painted.

Parameters:
b - if true, the focus state is painted.
See Also:
isFocusPainted
 o setKeyAccelerator
 public void setKeyAccelerator(char aKey)
Convenience to set the key accelerator on the current model

 o getKeyAccelerator
 public char getKeyAccelerator()
Convenience to get the accelerator from the the current model

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

See Also:
setModel
 o setModel
 public void setModel(ButtonModel newModel)
Set the model that this button represents.

Parameters:
m - the Model
See Also:
getModel
 o getUI
 public ButtonUI getUI()
Returns the button's current UI.

See Also:
setUI
 o setUI
 public void setUI(ButtonUI ui)
Sets the button's UI.

Parameters:
ui - the new ButtonUI
See Also:
getUI
 o updateUI
 public void updateUI()
Gets a new UI object from the default UIFactory.

Overrides:
updateUI in class JComponent
 o addChangeListener
 public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the button.

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

 o addActionListener
 public void addActionListener(ActionListener l)
adds an ActionListener to the button

 o removeActionListener
 public void removeActionListener(ActionListener l)
removes an ActionListener from the button

 o createChangeListener
 protected ChangeListener createChangeListener()
 o createActionListener
 protected ActionListener createActionListener()
 o createItemListener
 protected ItemListener createItemListener()
 o setEnabled
 public void setEnabled(boolean b)
Enables (or disables) the button.

Overrides:
setEnabled in class Component
 o getAlignmentX
 public float getAlignmentX()
Set the default horizontal alignment left

Overrides:
getAlignmentX in class JComponent
 o getLabel
 public String getLabel()
Note: getLabel() is deprecated. - Replaced by getText()

 o setLabel
 public void setLabel(String label)
Note: setLabel() is deprecated. - Replaced by setText(text)

 o addItemListener
 public void addItemListener(ItemListener l)
adds an ItemListener to the checkbox

 o removeItemListener
 public void removeItemListener(ItemListener l)
removes an ItemListener from the button

 o getSelectedObjects
 public Object[] getSelectedObjects()
 o init
 protected void init(String text,
                     Icon icon)
 o setBorder
 public void setBorder(Border border)
 o getBorder
 public Border getBorder()

All Packages  Class Hierarchy  This Package  Previous  Next  Index