JToggleButtonpublic class JToggleButton extends AbstractButton implements AccessibleAn implementation of a two-state button.
The JRadioButton and JCheckBox classes
are subclasses of this class.
For information on using them see
How to Use Buttons, Check Boxes, and Radio Buttons,
a section in The Java Tutorial.
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 JavaBeansTM
has been added to the java.beans package.
Please see {@link java.beans.XMLEncoder}. |
Fields Summary |
---|
private static final String | uiClassID |
Constructors Summary |
---|
public JToggleButton()Creates an initially unselected toggle button
without setting the text or image.
this(null, null, false);
| public JToggleButton(Icon icon)Creates an initially unselected toggle button
with the specified image but no text.
this(null, icon, false);
| public JToggleButton(Icon icon, boolean selected)Creates a toggle button with the specified image
and selection state, but no text.
this(null, icon, selected);
| public JToggleButton(String text)Creates an unselected toggle button with the specified text.
this(text, null, false);
| public JToggleButton(String text, boolean selected)Creates a toggle button with the specified text
and selection state.
this(text, null, selected);
| public JToggleButton(Action a)Creates a toggle button where properties are taken from the
Action supplied.
this();
setAction(a);
| public JToggleButton(String text, Icon icon)Creates a toggle button that has the specified text and image,
and that is initially unselected.
this(text, icon, false);
| public JToggleButton(String text, Icon icon, boolean selected)Creates a toggle button with the specified text, image, and
selection state.
// Create the model
setModel(new ToggleButtonModel());
model.setSelected(selected);
// initialize
init(text, icon);
|
Methods Summary |
---|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this JToggleButton.
For toggle buttons, the AccessibleContext takes the form of an
AccessibleJToggleButton.
A new AccessibleJToggleButton instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleJToggleButton();
}
return accessibleContext;
| public java.lang.String | getUIClassID()Returns a string that specifies the name of the l&f class
that renders this component.
return uiClassID;
| protected java.lang.String | paramString()Returns a string representation of this JToggleButton. This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null .
return super.paramString();
| public void | updateUI()Resets the UI property to a value from the current look and feel.
setUI((ButtonUI)UIManager.getUI(this));
| private void | writeObject(java.io.ObjectOutputStream s)See readObject() and writeObject() in JComponent for more
information about serialization in Swing.
s.defaultWriteObject();
if (getUIClassID().equals(uiClassID)) {
byte count = JComponent.getWriteObjCounter(this);
JComponent.setWriteObjCounter(this, --count);
if (count == 0 && ui != null) {
ui.installUI(this);
}
}
|
|