Skip to content

Commit 55ebf11

Browse files
committed
ButtonListener fix for JSlider premature setHTMLElement()
1 parent ad3c00b commit 55ebf11

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
package swingjs.plaf;
3030

3131
import java.awt.Container;
32+
import java.awt.JSComponent;
3233
import java.awt.event.ActionEvent;
3334
import java.awt.event.FocusEvent;
3435
import java.awt.event.FocusListener;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,18 +1222,18 @@ public void setTainted(boolean tf) {
12221222
public void stateChanged(ChangeEvent e) {
12231223
}
12241224

1225-
private void updatePropertyAncestor(boolean fromButtonListener) {
1225+
private void updatePropertyAncestor(boolean andSetHTML) {
12261226
// Q: Why is setTainted() within fromButtonListener -- here only, not below?
1227-
if (fromButtonListener) {
1228-
setTainted();
1227+
setTainted();
1228+
if (andSetHTML) {
12291229
setHTMLElement();
12301230
}
12311231
JComponent p = (JComponent) jc.getParent();
12321232
while (p != null) {
12331233
JSComponentUI parentui = (p == null ? null : p.秘getUI());
12341234
if (parentui != null) {
12351235
parentui.setTainted();
1236-
if (fromButtonListener) {
1236+
if (andSetHTML) {
12371237
parentui.setHTMLElement();
12381238
if (parentui.menu != null) {
12391239
((JSPopupMenuUI) parentui).updateMenu(false);
@@ -1308,7 +1308,8 @@ void propertyChangedFromListener(PropertyChangeEvent e, String prop) {
13081308
case "ancestor":
13091309
if (cellComponent != null)
13101310
return;
1311-
updatePropertyAncestor(true);
1311+
Container anc = JSComponent.秘getTopInvokableAncestor(c, false);
1312+
updatePropertyAncestor(anc != null && anc.isVisible());
13121313
break;
13131314
}
13141315
propertyChangedCUI(e, prop);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public DOMNode updateDOMNode() {
118118
setTainted();
119119
setInnerComponentBounds(jc.getWidth(), jc.getHeight());
120120
}
121-
setup(isNew || isChanged);
121+
setup(isNew || isChanged);
122122
setSlider();
123123
setBackground(getBackground());
124124
setForeground(getForeground());
@@ -324,7 +324,7 @@ protected void setSliderAttr(String key, float val) {
324324
* jsslider.j2sslider("option",key,val);
325325
*/
326326
} catch (Throwable t) {
327-
System.out.println(key + ":" + val + " could not be set for " + id);
327+
// System.out.println(key + ":" + val + " could not be set for " + id);
328328
// ignore -- disposal problem?
329329
}
330330
noSnapping = isScrollBar;
@@ -490,7 +490,7 @@ public void stateChanged(ChangeEvent e) {
490490

491491

492492
void setScrollBarExtentAndCSS() {
493-
// scrollbar subclass only
493+
// overridden in JSScrollBarUI
494494
}
495495

496496

@@ -532,7 +532,7 @@ public Dimension getPreferredHorizontalSize() {
532532
public Dimension getPreferredVerticalSize() {
533533
Dimension vertDim = (Dimension) DefaultLookup.get(slider, this,
534534
"Slider.verticalSize");
535-
return new Dimension(Math.max(vertDim.height, myHeight), vertDim.width);
535+
return new Dimension(Math.max(vertDim.width, myHeight), vertDim.height);
536536
}
537537

538538
/**
@@ -645,6 +645,8 @@ protected void setJSDimensions(int width, int height) {
645645
} else {
646646
DOMNode.setStyles(domNode, "left", ((width - myHeight) / 2) + "px", "width", myHeight + "px");
647647
}
648+
if (!isScrollBar)
649+
setSlider();
648650
}
649651

650652
// @Override

0 commit comments

Comments
 (0)