Buttons can be configured, and to some degree controlled, by
Actions. Using an
Action with a button has many benefits beyond directly
configuring a button. Refer to
Swing Components Supporting Action for more
details, and you can find more information in How
to Use Actions, a section in The Java Tutorial.
See How to Use Buttons, Check Boxes, and Radio Buttons in The Java Tutorial for information and examples of using buttons.
Warning
Swing is not thread safe. For more information see Swing's Threading Policy.
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. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Modifier and Type | Class and Description |
|---|---|
| protected class | JButton.
This class implements accessibility support for the
|
| Modifier and Type | Field and Description |
|---|---|
| private static final String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public AccessibleContext | Returns: anAccessibleJButton that serves as the
AccessibleContext of this JButtonOverrides java. Implements javax. Gets the |
| public String | Returns: the string "ButtonUI"Overrides javax. Returns a string that specifies the name of the L&F class that renders this component. |
| public boolean | Returns: the value of thedefaultButton propertyGets the value of the |
| public boolean | Returns: the value of thedefaultCapable propertyGets the value of the |
| protected String | Returns: a string representation of thisJButtonOverrides javax. Returns a string representation of this |
| public void | removeNotify()
Overrides javax. Overrides |
| public void | setDefaultCapable(boolean
true if this button will be
capable of being the default button on the
RootPane; otherwise falseSets the |
| public void | updateUI()
Overrides javax. Resets the UI property to a value from the current look and feel. |
| private void | writeObject(ObjectOutputStream s)
Hides javax. See readObject() and writeObject() in JComponent for more information about serialization in Swing. |
| uiClassID | back to summary |
|---|---|
| private static final String uiClassID Hides javax.
| |
| JButton | back to summary |
|---|---|
| public JButton() Creates a button with no set text or icon. | |
| JButton | back to summary |
|---|---|
| public JButton(Icon icon) Creates a button with an icon.
| |
| JButton | back to summary |
|---|---|
| public JButton(String text) Creates a button with text.
| |
| JButton | back to summary |
|---|---|
| public JButton(Action a) Creates a button where properties are taken from the
| |
| JButton | back to summary |
|---|---|
| public JButton(String text, Icon icon) Creates a button with initial text and an icon. | |
| getAccessibleContext | back to summary |
|---|---|
| public AccessibleContext getAccessibleContext() Overrides java. Implements javax. Gets the
| |
| getUIClassID | back to summary |
|---|---|
| public String getUIClassID() Overrides javax. Returns a string that specifies the name of the L&F class that renders this component.
| |
| isDefaultButton | back to summary |
|---|---|
| public boolean isDefaultButton() Gets the value of the
| |
| isDefaultCapable | back to summary |
|---|---|
| public boolean isDefaultCapable() Gets the value of the
| |
| paramString | back to summary |
|---|---|
| protected String paramString() Overrides javax. Returns a string representation of this
| |
| removeNotify | back to summary |
|---|---|
| public void removeNotify() Overrides javax. Overrides | |
| setDefaultCapable | back to summary |
|---|---|
| public void setDefaultCapable(boolean defaultCapable) Sets the
| |
| updateUI | back to summary |
|---|---|
| public void updateUI() Overrides javax. Resets the UI property to a value from the current look and feel.
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Hides javax. See readObject() and writeObject() in JComponent for more information about serialization in Swing.
| |
JButton class. It provides an implementation of the
Java Accessibility API appropriate to button user-interface
elements.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. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides javax. Get the role of this object. |
| AccessibleJButton | back to summary |
|---|---|
| protected AccessibleJButton() Constructs an | |
| getAccessibleRole | back to summary |
|---|---|
| public AccessibleRole getAccessibleRole() Overrides javax. Get the role of this object.
| |