Skip to content

Commit 6505133

Browse files
authored
Merge pull request #120 from BobHanson/master
better fix for checkbox issue
2 parents 886006a + e92691e commit 6505133

File tree

8 files changed

+14
-11
lines changed

8 files changed

+14
-11
lines changed
15 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190703083607
1+
20190703091927
15 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190703083607
1+
20190703091927
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
2019.07.03 bypass ButtonListener.verifyButtonClick if "checked" is set programmatically
21
2019.07.01 working on JSEditorPaneUI tab business
32
2019.07.01 AppContext.getApplet(name) initial work
4-
2019.07.01 working on JTable key navigation events
3+
2019.07.01 working on JTable key navigation events
4+
5+
6+
2019.07.03 DONE: bypass ButtonListener.verifyButtonClick delay if "checked" is set programmatically
15 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/swingjs/plaf/ButtonListener.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void updateMnemonicBinding(AbstractButton b) {
243243
@Override
244244
public void stateChanged(ChangeEvent e) {
245245
AbstractButton b = (AbstractButton) e.getSource();
246-
verifyButtonClick(b);
246+
verifyButtonClick(b, false);
247247
}
248248

249249
@Override
@@ -290,7 +290,7 @@ public void mouseReleased(MouseEvent e) {
290290
if (checkHideMenus(b))
291291
return;
292292
b.doClick(0);
293-
verifyButtonClick(b);
293+
verifyButtonClick(b, true);
294294
}
295295
}
296296

@@ -337,16 +337,18 @@ public void mouseExited(MouseEvent e) {
337337
*
338338
* @return true
339339
*/
340-
boolean verifyButtonClick(AbstractButton b) {
340+
boolean verifyButtonClick(AbstractButton b, boolean delayed) {
341341
ButtonModel m = b.getModel();
342342
DOMNode btn = ui.actionNode;
343+
if (btn == null)
344+
return true;
343345
boolean state = m.isSelected();
344346
/**
345347
* @j2sNative
346348
*
347-
* setTimeout(function(){
348-
* btn && btn.checked != state && (btn.checked = state);
349-
* }, 0);
349+
* if (delayed) { setTimeout(function(){ btn && btn.checked != state
350+
* && (btn.checked = state); }, 0); } else { btn.checked = state; }
351+
*
350352
*/
351353
{
352354
System.out.println("" + btn + state);

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSRadioButtonUI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public boolean handleJSEvent(Object target, int eventType, Object jQueryEvent) {
7878
protected void setupButton(JToggleButton b, boolean doAll) {
7979
// actionNode, iconNode, textNode, centeringNode, buttonNode
8080
DOMNode.setAttr(actionNode, "checked", b.isSelected() ? TRUE : FALSE);
81-
buttonListener.verifyButtonClick(b); // necessary!
8281
setCssFont(textNode, c.getFont());
8382
// TODO: not allowing radio/checkbox icons (custom buttons)
8483
setIconAndText("radio", (ImageIcon) null/* button.getIcon() */, button.getIconTextGap(), button.getText());

0 commit comments

Comments
 (0)