1 /* CheckboxGroup.java -- A grouping class for checkboxes.
2 Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
31 * This class if for combining checkboxes into groups so that only
32 * one checkbox in the group can be selected at any one time.
34 * @author Aaron M. Renn (arenn@urbanophile.com)
35 * @author Tom Tromey <tromey@redhat.com>
37 public class CheckboxGroup implements java.io.Serializable
44 // Serialization constant
45 private static final long serialVersionUID = 3729780091441768983L;
47 /*************************************************************************/
54 * @serial The currently selected checkbox.
56 private Checkbox selectedCheckbox;
58 /*************************************************************************/
65 * Initializes a new instance of <code>CheckboxGroup</code>.
72 /*************************************************************************/
79 * Returns the currently selected checkbox, or <code>null</code> if none
80 * of the checkboxes in this group are selected.
82 * @return The selected checkbox.
87 return(selectedCheckbox);
90 /*************************************************************************/
93 * Returns the currently selected checkbox, or <code>null</code> if none
94 * of the checkboxes in this group are selected.
96 * @return The selected checkbox.
98 * @deprecated This method is deprecated in favor of
99 * <code>getSelectedCheckbox()</code>.
104 return(selectedCheckbox);
107 /*************************************************************************/
110 * This method sets the specified checkbox to be the selected on in this
111 * group, and unsets all others.
113 * @param selectedCheckbox The new selected checkbox.
116 setSelectedCheckbox(Checkbox selectedCheckbox)
118 if (this.selectedCheckbox != null)
120 if (this.selectedCheckbox.getCheckboxGroup() != this)
123 this.selectedCheckbox.setState(false);
126 this.selectedCheckbox = selectedCheckbox;
127 if (selectedCheckbox != null)
128 selectedCheckbox.setState(true);
131 /*************************************************************************/
134 * This method sets the specified checkbox to be the selected on in this
135 * group, and unsets all others.
137 * @param selectedCheckbox The new selected checkbox.
139 * @deprecated This method is deprecated in favor of
140 * <code>setSelectedCheckbox()</code>.
143 setCurrent(Checkbox selectedCheckbox)
145 setSelectedCheckbox(selectedCheckbox);
148 /*************************************************************************/
151 * Returns a string representation of this checkbox group.
153 * @return A string representation of this checkbox group.
158 return(getClass().getName() + "[selectedCheckbox=" + selectedCheckbox + "]");
161 } // class CheckboxGroup