1 /* ButtonModel.java -- 2 Copyright (C) 2002, 2004 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 javax.swing; 40 41 import java.awt.ItemSelectable; 42 import java.awt.event.ActionListener; 43 import java.awt.event.ItemListener; 44 45 import javax.swing.event.ChangeListener; 46 47 /** 48 * The data model that is used in all kinds of buttons. 49 */ 50 public interface ButtonModel extends ItemSelectable 51 { 52 53 /** 54 * Returns <code>true</code> if the button is armed, <code>false</code> 55 * otherwise. 56 * 57 * A button is armed, when the user has pressed the mouse over it, but has 58 * not yet released the mouse. 59 * 60 * @return <code>true</code> if the button is armed, <code>false</code> 61 * otherwise 62 * 63 * @see #setArmed(boolean) 64 */ isArmed()65 boolean isArmed(); 66 67 /** 68 * Sets the armed flag of the button. 69 * 70 * A button is armed, when the user has pressed the mouse over it, but has 71 * not yet released the mouse. 72 * 73 * @param b <code>true</code> if the button is armed, <code>false</code> 74 * otherwise 75 * 76 * @see #isArmed() 77 */ setArmed(boolean b)78 void setArmed(boolean b); 79 80 /** 81 * Returns <code>true</code> if the button is enabled, <code>false</code> 82 * otherwise. 83 * 84 * When a button is disabled, it is usually grayed out and the user cannot 85 * change its state. 86 * 87 * @return <code>true</code> if the button is enabled, <code>false</code> 88 * otherwise 89 * 90 * @see #setEnabled(boolean) 91 */ isEnabled()92 boolean isEnabled(); 93 94 /** 95 * Sets the enabled flag of the button. 96 * 97 * When a button is disabled, it is usually grayed out and the user cannot 98 * change its state. 99 * 100 * @param b <code>true</code> if the button is enabled, <code>false</code> 101 * otherwise 102 * 103 * @see #isEnabled() 104 */ setEnabled(boolean b)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 */ setPressed(boolean b)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 */ isPressed()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 */ removeActionListener(ActionListener l)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 */ addActionListener(ActionListener l)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 */ addItemListener(ItemListener l)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 */ removeItemListener(ItemListener l)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 */ addChangeListener(ChangeListener l)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 */ removeChangeListener(ChangeListener l)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 */ setRollover(boolean b)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 */ isRollover()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 */ getMnemonic()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 */ setMnemonic(int key)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 */ setActionCommand(String s)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 */ getActionCommand()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 */ setGroup(ButtonGroup group)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 */ setSelected(boolean b)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 */ isSelected()300 boolean isSelected(); 301 } 302