OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / libjava / classpath / java / awt / CheckboxGroup.java
1 /* CheckboxGroup.java -- A grouping class for checkboxes.
2    Copyright (C) 1999, 2000, 2002, 2005  Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
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)
9 any later version.
10
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.
15
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., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38
39 package java.awt;
40
41 /**
42   * This class if for combining checkboxes into groups so that only
43   * one checkbox in the group can be selected at any one time.
44   *
45   * @author Aaron M. Renn (arenn@urbanophile.com)
46   * @author Tom Tromey (tromey@redhat.com)
47   */
48 public class CheckboxGroup implements java.io.Serializable
49 {
50
51 /*
52  * Static Variables
53  */
54
55 // Serialization constant
56 private static final long serialVersionUID = 3729780091441768983L;
57
58 /*************************************************************************/
59
60 /*
61  * Instance Variables
62  */
63
64 /**
65   * @serial The currently selected checkbox.
66   */
67 private Checkbox selectedCheckbox;
68
69 /*************************************************************************/
70
71 /*
72  * Constructors
73  */
74
75 /**
76   * Initializes a new instance of <code>CheckboxGroup</code>.
77   */
78 public
79 CheckboxGroup()
80 {
81 }
82
83 /*************************************************************************/
84
85 /*
86  * Instance Methods
87  */
88
89 /**
90   * Returns the currently selected checkbox, or <code>null</code> if none
91   * of the checkboxes in this group are selected.
92   *
93   * @return The selected checkbox.
94   */
95 public Checkbox
96 getSelectedCheckbox()
97 {
98   return getCurrent ();
99 }
100
101 /*************************************************************************/
102
103 /**
104   * Returns the currently selected checkbox, or <code>null</code> if none
105   * of the checkboxes in this group are selected.
106   *
107   * @return The selected checkbox.
108   *
109   * @deprecated This method is deprecated in favor of 
110   * <code>getSelectedCheckbox()</code>.
111   */
112 public Checkbox
113 getCurrent()
114 {
115   return(selectedCheckbox);
116
117
118 /*************************************************************************/
119
120 /**
121   * This method sets the specified checkbox to be the selected on in this
122   * group, and unsets all others.
123   *
124   * @param selectedCheckbox The new selected checkbox.
125   */
126 public void
127 setSelectedCheckbox(Checkbox selectedCheckbox)
128 {
129   setCurrent (selectedCheckbox);
130 }
131
132 /*************************************************************************/
133
134 /**
135   * This method sets the specified checkbox to be the selected on in this
136   * group, and unsets all others.
137   *
138   * @param selectedCheckbox The new selected checkbox.
139   *
140   * @deprecated This method is deprecated in favor of
141   * <code>setSelectedCheckbox()</code>.
142   */
143 public void
144 setCurrent(Checkbox selectedCheckbox)
145 {
146   if (this.selectedCheckbox != null)
147     {
148       if (this.selectedCheckbox.getCheckboxGroup() != this)
149         return;
150
151       this.selectedCheckbox.setState(false);
152     }
153
154   this.selectedCheckbox = selectedCheckbox;
155   if (selectedCheckbox != null)
156     selectedCheckbox.setState(true);
157 }
158
159 /*************************************************************************/
160
161 /**
162   * Returns a string representation of this checkbox group.
163   *
164   * @return A string representation of this checkbox group.
165   */
166 public String
167 toString()
168 {
169   return(getClass().getName() + "[selectedCheckbox=" + selectedCheckbox + "]");
170 }
171
172 } // class CheckboxGroup 
173