Skip to content

Commit a98b517

Browse files
authored
Merge pull request #104 from BobHanson/hanson1
checkbox setting issues resolved
2 parents e0d797a + 1dadc7f commit a98b517

File tree

10 files changed

+16
-13
lines changed

10 files changed

+16
-13
lines changed
212 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190702213116
1+
20190703083607
212 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190702213116
1+
20190703083607
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
2019.07.03 bypass ButtonListener.verifyButtonClick if "checked" is set programmatically
12
2019.07.01 working on JSEditorPaneUI tab business
23
2019.07.01 AppContext.getApplet(name) initial work
34
2019.07.01 working on JTable key navigation events
212 Bytes
Binary file not shown.

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,9 @@ public void mouseExited(MouseEvent e) {
329329
}
330330

331331
/**
332-
* Just ensure the button is in sync by forcing the HTML5 DOM button to the same
333-
* setting as Java.
332+
* It is necessary that this method be called any time the "CHECKED" attribute
333+
* of a toggle button is changed. Otherwise it may fire for a previous state
334+
* after the state is changed in code directly.
334335
*
335336
* @param m
336337
*
@@ -339,12 +340,13 @@ public void mouseExited(MouseEvent e) {
339340
boolean verifyButtonClick(AbstractButton b) {
340341
ButtonModel m = b.getModel();
341342
DOMNode btn = ui.actionNode;
342-
// BH: I don't know that this is necessary anymore
343-
boolean state = m.isSelected();// && !ui.isRadio;
343+
boolean state = m.isSelected();
344344
/**
345345
* @j2sNative
346346
*
347-
* setTimeout(function(){btn && (btn.checked = state)}, 0);
347+
* setTimeout(function(){
348+
* btn && btn.checked != state && (btn.checked = state);
349+
* }, 0);
348350
*/
349351
{
350352
System.out.println("" + btn + state);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ protected DOMNode setCssFont(DOMNode obj, Font font) {
15061506
"font-weight", ((istyle & Font.BOLD) == 0 ? "normal" : "bold"));
15071507
}
15081508

1509+
// force the issue
15091510
enabled = !c.isEnabled();
15101511
setEnabled(c.isEnabled());
15111512
return obj;
@@ -2110,7 +2111,7 @@ protected void enableNode(DOMNode node, boolean b) {
21102111
if (node == null)
21112112
return;
21122113

2113-
DOMNode.setAttr(node, "disabled", (b ? null : TRUE));
2114+
DOMNode.setAttr(node, "disabled", (b ? FALSE : TRUE));
21142115
if (!b && inactiveForeground == colorUNKNOWN)
21152116
getDisabledColors(buttonNode == null ? getPropertyPrefix() : "Button");
21162117
if (jc.isOpaque()) {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ public boolean handleJSEvent(Object target, int eventType, Object jQueryEvent) {
7777

7878
protected void setupButton(JToggleButton b, boolean doAll) {
7979
// actionNode, iconNode, textNode, centeringNode, buttonNode
80-
81-
DOMNode.setAttr(actionNode, "checked", b.isSelected() ? TRUE : null);
82-
80+
DOMNode.setAttr(actionNode, "checked", b.isSelected() ? TRUE : FALSE);
81+
buttonListener.verifyButtonClick(b); // necessary!
8382
setCssFont(textNode, c.getFont());
8483
// TODO: not allowing radio/checkbox icons (custom buttons)
8584
setIconAndText("radio", (ImageIcon) null/* button.getIcon() */, button.getIconTextGap(), button.getText());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public abstract class JSTextUI extends JSLightweightUI {// implements {ViewFacto
130130
protected static final EditorKit defaultKit = new DefaultEditorKit();
131131

132132
static final Point markDot = new Point();
133-
133+
134134
transient JTextComponent editor;
135135
protected boolean editable = true;
136136
protected RootView rootView = new RootView();
@@ -293,7 +293,7 @@ protected void setColors(String prefix) {
293293
if ((dfg == null) || (dfg instanceof UIResource)) {
294294
editor.setDisabledTextColor(UIManager.getColor(prefix + ".inactiveForeground"));
295295
}
296-
dfg = UIManager.getColor(prefix + ".inactiveBackground");
296+
dfg = UIManager.getColor(editor.秘isAWT() ? "control" : prefix + ".inactiveBackground");
297297
if (dfg != null)
298298
inactiveBackground = dfg;
299299

0 commit comments

Comments
 (0)