133 |
/** |
/** |
134 |
* Sets the pressed state of the button. The selected state |
* Sets the pressed state of the button. The selected state |
135 |
* of the button also changes follwing the button being pressed. |
* of the button also changes follwing the button being pressed. |
|
* Unlike DefaultButtonModel, does not fire an ActionEvent. |
|
136 |
* |
* |
137 |
* @param b true if the button is pressed down. |
* @param b true if the button is pressed down. |
138 |
*/ |
*/ |
158 |
// setPressed(false) == mouse release on us, |
// setPressed(false) == mouse release on us, |
159 |
// if we were armed, we flip the selected state. |
// if we were armed, we flip the selected state. |
160 |
if (!p && isArmed()) |
if (!p && isArmed()) |
161 |
setSelected(! isSelected()); |
{ |
162 |
} |
fireActionPerformed(new ActionEvent(this, |
163 |
|
ActionEvent.ACTION_PERFORMED, |
164 |
/** |
actionCommand)); |
165 |
* Sets the selected state of the button. Unlike DefaultButtonModel, |
setSelected(! isSelected()); |
166 |
* fires an ActionEvent. |
} |
|
* |
|
|
* @param s true if button is selected |
|
|
*/ |
|
|
public void setSelected(boolean s) |
|
|
{ |
|
|
super.setSelected(s); |
|
|
fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, |
|
|
actionCommand)); |
|
167 |
} |
} |
168 |
} |
} |
169 |
|
|
260 |
*/ |
*/ |
261 |
public JToggleButton (String text, Icon icon, boolean selected) |
public JToggleButton (String text, Icon icon, boolean selected) |
262 |
{ |
{ |
263 |
super(text, icon); |
super(); |
264 |
|
init(text, icon); |
265 |
|
|
266 |
setModel(new ToggleButtonModel()); |
setModel(new ToggleButtonModel()); |
267 |
model.setSelected(selected); |
model.setSelected(selected); |