Skip to content

Commit 334a72b

Browse files
hansonrhansonr
authored andcommitted
AWT Checkbox setState needs to bypass listeners but still set ui
1 parent 7ec3c64 commit 334a72b

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

sources/net.sf.j2s.java.core/src/javax/swing/DefaultButtonModel.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,8 @@ public void setEnabled(boolean b) {
232232
*/
233233
@Override
234234
public void setSelected(boolean b) {
235-
if (this.isSelected() == b) {
236-
return;
237-
}
238-
239-
if (b) {
240-
stateMask |= SELECTED;
241-
} else {
242-
stateMask &= ~SELECTED;
243-
}
244-
235+
if (!setStateNoFire(b))
236+
return;
245237
fireItemStateChanged(
246238
new ItemEvent(this,
247239
ItemEvent.ITEM_STATE_CHANGED,
@@ -252,17 +244,16 @@ public void setSelected(boolean b) {
252244

253245
}
254246

255-
public void setStateNoFire(boolean b) {
247+
public boolean setStateNoFire(boolean b) {
256248
if (this.isSelected() == b) {
257-
return;
249+
return false;
258250
}
259-
260251
if (b) {
261252
stateMask |= SELECTED;
262253
} else {
263254
stateMask &= ~SELECTED;
264255
}
265-
256+
return true;
266257
}
267258

268259

sources/net.sf.j2s.java.core/src/swingjs/a2s/Checkbox.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import javax.swing.JCheckBox;
1010
import javax.swing.JRadioButton;
1111

12+
import swingjs.plaf.JSCheckBoxUI;
13+
1214
public class Checkbox extends JCheckBox {
1315

1416

@@ -73,7 +75,8 @@ public boolean getState() {
7375
}
7476

7577
public void setState(boolean b) {
76-
((DefaultButtonModel) model).setStateNoFire(b);
78+
if (((DefaultButtonModel) model).setStateNoFire(b))
79+
((JSCheckBoxUI) (Object) getUI()).updateDOMNode();
7780
}
7881

7982
public void setCheckboxGroup(java.awt.CheckboxGroup group) throws HeadlessException {

0 commit comments

Comments
 (0)