001 /* ButtonModel.java --
002 Copyright (C) 2002, 2004 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package javax.swing;
040
041 import java.awt.ItemSelectable;
042 import java.awt.event.ActionListener;
043 import java.awt.event.ItemListener;
044
045 import javax.swing.event.ChangeListener;
046
047 /**
048 * The data model that is used in all kinds of buttons.
049 */
050 public interface ButtonModel extends ItemSelectable
051 {
052
053 /**
054 * Returns <code>true</code> if the button is armed, <code>false</code>
055 * otherwise.
056 *
057 * A button is armed, when the user has pressed the mouse over it, but has
058 * not yet released the mouse.
059 *
060 * @return <code>true</code> if the button is armed, <code>false</code>
061 * otherwise
062 *
063 * @see #setArmed(boolean)
064 */
065 boolean isArmed();
066
067 /**
068 * Sets the armed flag of the button.
069 *
070 * A button is armed, when the user has pressed the mouse over it, but has
071 * not yet released the mouse.
072 *
073 * @param b <code>true</code> if the button is armed, <code>false</code>
074 * otherwise
075 *
076 * @see #isArmed()
077 */
078 void setArmed(boolean b);
079
080 /**
081 * Returns <code>true</code> if the button is enabled, <code>false</code>
082 * otherwise.
083 *
084 * When a button is disabled, it is usually grayed out and the user cannot
085 * change its state.
086 *
087 * @return <code>true</code> if the button is enabled, <code>false</code>
088 * otherwise
089 *
090 * @see #setEnabled(boolean)
091 */
092 boolean isEnabled();
093
094 /**
095 * Sets the enabled flag of the button.
096 *
097 * When a button is disabled, it is usually grayed out and the user cannot
098 * change its state.
099 *
100 * @param b <code>true</code> if the button is enabled, <code>false</code>
101 * otherwise
102 *
103 * @see #isEnabled()
104 */
105 void setEnabled(boolean b);
106
107 /**
108 * Sets the pressed flag of the button.
109 *
110 * The button usually gets pressed when the user clicks on a button, it will
111 * be un-pressed when the user releases the mouse.
112 *
113 * @param b <code>true</code> if the button is pressed, <code>false</code>
114 * otherwise
115 *
116 * @see #isPressed()
117 */
118 void setPressed(boolean b);
119
120 /**
121 * Returns <code>true</code> if the button is pressed, <code>false</code>
122 * otherwise.
123 *
124 * The button usually gets pressed when the user clicks on a button, it will
125 * be un-pressed when the user releases the mouse.
126 *
127 * @return <code>true</code> if the button is pressed, <code>false</code>
128 * otherwise
129 *
130 * @see #setPressed(boolean)
131 */
132 boolean isPressed();
133
134 /**
135 * Removes an {@link ActionListener} from the list of registered listeners.
136 *
137 * @param l the action listener to remove
138 *
139 * @see #addActionListener(ActionListener)
140 */
141 void removeActionListener(ActionListener l);
142
143 /**
144 * Adds an {@link ActionListener} to the list of registered listeners.
145 *
146 * An <code>ActionEvent</code> is usually fired when the user clicks on a
147 * button.
148 *
149 * @param l the action listener to add
150 *
151 * @see #removeActionListener(ActionListener)
152 */
153 void addActionListener(ActionListener l);
154
155 /**
156 * Adds an {@link ItemListener} to the list of registered listeners.
157 *
158 * An <code>ItemEvent</code> is usually fired when a button's selected
159 * state changes. This applies only to buttons that support the selected
160 * flag.
161 *
162 * @param l the item listener to add
163 *
164 * @see #removeItemListener(ItemListener)
165 */
166 void addItemListener(ItemListener l);
167
168 /**
169 * Adds an {@link ItemListener} to the list of registered listeners.
170 *
171 * @param l the item listener to add
172 *
173 * @see #removeItemListener(ItemListener)
174 */
175 void removeItemListener(ItemListener l);
176
177 /**
178 * Adds an {@link ChangeListener} to the list of registered listeners.
179 *
180 * A <code>ChangeEvent</code> is fired when any one of the button's flags
181 * changes.
182 *
183 * @param l the change listener to add
184 *
185 * @see #removeChangeListener(ChangeListener)
186 */
187 void addChangeListener(ChangeListener l);
188
189 /**
190 * Adds an {@link ChangeListener} to the list of registered listeners.
191 *
192 * @param l the change listener to add
193 *
194 * @see #removeChangeListener(ChangeListener)
195 */
196 void removeChangeListener(ChangeListener l);
197
198 /**
199 * Sets the rollover flag of the button.
200 *
201 * A button is rollover-ed, when the user has moved the mouse over it, but has
202 * not yet pressed the mouse.
203 *
204 * @param b <code>true</code> if the button is rollover, <code>false</code>
205 * otherwise
206 *
207 * @see #isRollover()
208 */
209 void setRollover(boolean b);
210
211 /**
212 * Returns <code>true</code> if the button is rollover-ed, <code>false</code>
213 * otherwise.
214 *
215 * A button is rollover-ed, when the user has moved the mouse over it, but has
216 * not yet pressed the mouse.
217 *
218 * @return <code>true</code> if the button is rollover, <code>false</code>
219 * otherwise
220 *
221 * @see #setRollover(boolean)
222 */
223 boolean isRollover();
224
225 /**
226 * Returns the keyboard mnemonic for the button. This specifies a shortcut
227 * or accelerator key that can be used to activate the button.
228 *
229 * @return the keyboard mnemonic for the button
230 *
231 * @see #setMnemonic(int)
232 */
233 int getMnemonic();
234
235 /**
236 * Sets the keyboard mnemonic for the button. This specifies a shortcut
237 * or accelerator key that can be used to activate the button.
238 *
239 * @param key the keyboard mnemonic for the button
240 *
241 * @see #getMnemonic()
242 */
243 void setMnemonic(int key);
244
245 /**
246 * Sets the action command for the button. This will be used in
247 * <code>ActionEvents</code> fired by the button.
248 *
249 * @param s the action command to set
250 *
251 * @see #getActionCommand()
252 */
253 void setActionCommand(String s);
254
255 /**
256 * Returns the action command of the button.
257 *
258 * @return the action command of the button
259 *
260 * @see #setActionCommand(String)
261 */
262 String getActionCommand();
263
264 /**
265 * Sets the button group for the button. Some kinds of button (e.g. radio
266 * buttons) allow only one button within a button group selected at any one
267 * time.
268 *
269 * @param group the button group to set
270 */
271 void setGroup(ButtonGroup group);
272
273 /**
274 * Sets the selected flag of the button.
275 *
276 * Some kinds of buttons (e.g. toggle buttons, check boxes, radio buttons)
277 * can be in one of two states: selected or unselected. The selected state
278 * is usually toggled by clicking on the button.
279 *
280 * @param b <code>true</code> if the button is selected, <code>false</code>
281 * otherwise
282 *
283 * @see #isSelected()
284 */
285 void setSelected(boolean b);
286
287 /**
288 * Returns <code>true</code> if the button is selected, <code>false</code>
289 * otherwise.
290 *
291 * Some kinds of buttons (e.g. toggle buttons, check boxes, radio buttons)
292 * can be in one of two states: selected or unselected. The selected state
293 * is usually toggled by clicking on the button.
294 *
295 * @return <code>true</code> if the button is selected, <code>false</code>
296 * otherwise
297 *
298 * @see #setSelected(boolean)
299 */
300 boolean isSelected();
301 }