1 /*
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
74 public CheckboxGroup() {
75 }
76
77 /**
78 * Gets the current choice from this check box group.
79 * The current choice is the check box in this
80 * group that is currently in the "on" state,
81 * or <code>null</code> if all check boxes in the
82 * group are off.
83 * @return the check box that is currently in the
84 * "on" state, or <code>null</code>.
85 * @see java.awt.Checkbox
86 * @see java.awt.CheckboxGroup#setSelectedCheckbox
87 * @since JDK1.1
88 */
89 public Checkbox getSelectedCheckbox() {
90 return getCurrent();
91 }
92
93 /**
94 * @deprecated As of JDK version 1.1,
95 * replaced by <code>getSelectedCheckbox()</code>.
96 */
97 @Deprecated
98 public Checkbox getCurrent() {
99 return selectedCheckbox;
100 }
101
102 /**
103 * Sets the currently selected check box in this group
104 * to be the specified check box.
105 * This method sets the state of that check box to "on" and
106 * sets all other check boxes in the group to be off.
107 * <p>
108 * If the check box argument is <tt>null</tt>, all check boxes
109 * in this check box group are deselected. If the check box argument
110 * belongs to a different check box group, this method does
111 * nothing.
112 * @param box the <code>Checkbox</code> to set as the
113 * current selection.
114 * @see java.awt.Checkbox
115 * @see java.awt.CheckboxGroup#getSelectedCheckbox
116 * @since JDK1.1
117 */
118 public void setSelectedCheckbox(Checkbox box) {
119 setCurrent(box);
120 }
121
122 /**
123 * @deprecated As of JDK version 1.1,
124 * replaced by <code>setSelectedCheckbox(Checkbox)</code>.
125 */
126 @Deprecated
127 public synchronized void setCurrent(Checkbox box) {
128 if (box != null && box.group != this) {
129 return;
130 }
131 Checkbox oldChoice = this.selectedCheckbox;
132 this.selectedCheckbox = box;
133 if (oldChoice != null && oldChoice != box && oldChoice.group == this) {
134 oldChoice.setState(false);
135 }
136 if (box != null && oldChoice != box && !box.getState()) {
137 box.setStateInternal(true);
138 }
139 }
140
141 /**
142 * Returns a string representation of this check box group,
|
1 /*
2 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
74 public CheckboxGroup() {
75 }
76
77 /**
78 * Gets the current choice from this check box group.
79 * The current choice is the check box in this
80 * group that is currently in the "on" state,
81 * or <code>null</code> if all check boxes in the
82 * group are off.
83 * @return the check box that is currently in the
84 * "on" state, or <code>null</code>.
85 * @see java.awt.Checkbox
86 * @see java.awt.CheckboxGroup#setSelectedCheckbox
87 * @since JDK1.1
88 */
89 public Checkbox getSelectedCheckbox() {
90 return getCurrent();
91 }
92
93 /**
94 * Returns the current choice from this check box group
95 * or {@code null} if none of checkboxes are selected.
96 *
97 * @return the selected checkbox
98 * @deprecated As of JDK version 1.1,
99 * replaced by <code>getSelectedCheckbox()</code>.
100 */
101 @Deprecated
102 public Checkbox getCurrent() {
103 return selectedCheckbox;
104 }
105
106 /**
107 * Sets the currently selected check box in this group
108 * to be the specified check box.
109 * This method sets the state of that check box to "on" and
110 * sets all other check boxes in the group to be off.
111 * <p>
112 * If the check box argument is <tt>null</tt>, all check boxes
113 * in this check box group are deselected. If the check box argument
114 * belongs to a different check box group, this method does
115 * nothing.
116 * @param box the <code>Checkbox</code> to set as the
117 * current selection.
118 * @see java.awt.Checkbox
119 * @see java.awt.CheckboxGroup#getSelectedCheckbox
120 * @since JDK1.1
121 */
122 public void setSelectedCheckbox(Checkbox box) {
123 setCurrent(box);
124 }
125
126 /**
127 * Sets the currently selected check box in this group
128 * to be the specified check box and unsets all others.
129 *
130 * @param box the {@code Checkbox} to set as the
131 * current selection.
132 * @deprecated As of JDK version 1.1,
133 * replaced by <code>setSelectedCheckbox(Checkbox)</code>.
134 */
135 @Deprecated
136 public synchronized void setCurrent(Checkbox box) {
137 if (box != null && box.group != this) {
138 return;
139 }
140 Checkbox oldChoice = this.selectedCheckbox;
141 this.selectedCheckbox = box;
142 if (oldChoice != null && oldChoice != box && oldChoice.group == this) {
143 oldChoice.setState(false);
144 }
145 if (box != null && oldChoice != box && !box.getState()) {
146 box.setStateInternal(true);
147 }
148 }
149
150 /**
151 * Returns a string representation of this check box group,
|