aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/swing/ButtonGroup.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2006-08-14 23:12:35 +0000
committerMark Wielaard <mark@gcc.gnu.org>2006-08-14 23:12:35 +0000
commitac1ed908de999523efc36f38e69bca1aadfe0808 (patch)
tree97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/javax/swing/ButtonGroup.java
parentabab460491408e05ea93fb85e1975296a87df504 (diff)
downloadgcc-ac1ed908de999523efc36f38e69bca1aadfe0808.zip
gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.tar.gz
gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.tar.bz2
Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org> Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. From-SVN: r116139
Diffstat (limited to 'libjava/classpath/javax/swing/ButtonGroup.java')
-rw-r--r--libjava/classpath/javax/swing/ButtonGroup.java53
1 files changed, 34 insertions, 19 deletions
diff --git a/libjava/classpath/javax/swing/ButtonGroup.java b/libjava/classpath/javax/swing/ButtonGroup.java
index 2f8d198..efa36b5 100644
--- a/libjava/classpath/javax/swing/ButtonGroup.java
+++ b/libjava/classpath/javax/swing/ButtonGroup.java
@@ -1,5 +1,5 @@
/* ButtonGroup.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -65,10 +65,9 @@ import java.util.Vector;
*/
public class ButtonGroup implements Serializable
{
- /** DOCUMENT ME! */
private static final long serialVersionUID = 4259076101881721375L;
- /** The buttons added to this button group. */
+ /** Stores references to the buttons added to this button group. */
protected Vector buttons = new Vector();
/** The currently selected button model. */
@@ -83,12 +82,20 @@ public class ButtonGroup implements Serializable
}
/**
- * Adds a button to this group.
+ * Adds a button to this group. If the button is in the selected state, then:
+ * <ul>
+ * <li>if the group has no current selection, the new button becomes the
+ * selected button for the group;</li>
+ * <li>if the group already has a selected button, the new button is set to
+ * "not selected".</li>
+ * </ul>
*
- * @param b the button to add
+ * @param b the button to add (<code>null</code> is ignored).
*/
public void add(AbstractButton b)
{
+ if (b == null)
+ return;
b.getModel().setGroup(this);
if (b.isSelected())
{
@@ -96,17 +103,24 @@ public class ButtonGroup implements Serializable
sel = b.getModel();
else
b.setSelected(false);
- } buttons.addElement(b);
+ }
+ buttons.addElement(b);
}
/**
- * Removed a given button from this group.
+ * Removes the specified button from this group. If the button is the
+ * selected button, the current selection is set to <code>null</code>.
+ * The group for the removed button's model is set to <code>null</code>.
*
- * @param b the button to remove
+ * @param b the button to remove (<code>null</code> is ignored).
*/
public void remove(AbstractButton b)
{
+ if (b == null)
+ return;
b.getModel().setGroup(null);
+ if (b.getModel() == sel)
+ sel = null;
buttons.removeElement(b);
}
@@ -132,19 +146,20 @@ public class ButtonGroup implements Serializable
}
/**
- * DOCUMENT ME!
+ * Returns the button that has the specified model, or <code>null</code> if
+ * there is no such button in the group.
*
- * @param m DOCUMENT ME!
+ * @param m the button model.
*
- * @return DOCUMENT ME!
+ * @return The button that has the specified model, or <code>null</code>.
*/
- AbstractButton FindButton(ButtonModel m)
+ AbstractButton findButton(ButtonModel m)
{
for (int i = 0; i < buttons.size(); i++)
{
- AbstractButton a = (AbstractButton) buttons.get(i);
- if (a.getModel() == m)
- return a;
+ AbstractButton a = (AbstractButton) buttons.get(i);
+ if (a.getModel() == m)
+ return a;
}
return null;
}
@@ -168,7 +183,7 @@ public class ButtonGroup implements Serializable
if (old != null)
old.setSelected(false);
- AbstractButton button = FindButton(old);
+ AbstractButton button = findButton(old);
if (button != null)
button.repaint();
}
@@ -180,10 +195,10 @@ public class ButtonGroup implements Serializable
* Checks if the given <code>ButtonModel</code> is selected in this button
* group.
*
- * @param m DOCUMENT ME!
+ * @param m the button model (<code>null</code> permitted).
*
- * @return true of given <code>ButtonModel</code> is selected, false
- * otherwise
+ * @return <code>true</code> if <code>m</code> is the selected button model
+ * in this group, and <code>false</code> otherwise.
*/
public boolean isSelected(ButtonModel m)
{