Skip to content

Commit 333859d

Browse files
hansonrhansonr
authored andcommitted
JSSlider fixes to avoid unnecessary caught early exception
1 parent cdc875d commit 333859d

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,7 @@ private void uninstallJS() {
680680
protected JQueryObject $(Object node) {
681681
return jquery.$(node);
682682
}
683-
protected Object $data(DOMNode node, String attr) {
684-
return (node == null ? null : jquery.data(node,attr));
685-
}
686-
683+
687684
/**
688685
* Set the associated JComponent. Setting comp null will disable this UI from
689686
* getting any events.

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import swingjs.JSToolkit;
3232
import swingjs.JSUtil;
3333
import swingjs.api.js.DOMNode;
34+
import swingjs.api.js.JQueryObject;
3435
import swingjs.jquery.JQueryUI;
3536

3637
/**
@@ -349,30 +350,33 @@ private void setup(boolean isNew) {
349350

350351
/**
351352
* Call jquery-ui-j2sslider.js _setOption
353+
*
352354
* @param key
353355
* @param val
354356
*/
355357
protected void setSliderAttr(String key, float val) {
356-
if (!sliderInitialized())
357-
noSnapping = true;
358-
String id = null;
359-
try {
360-
Object jsslider = $(jqSlider);
361-
/**
362-
* @j2sNative
363-
*
364-
* id = this.jqSlider.id;
365-
* jsslider.j2sslider("option",key,val);
366-
*/
367-
} catch (Throwable t) {
368-
// System.out.println(key + ":" + val + " could not be set for " + id);
369-
// ignore -- disposal problem?
358+
if (sliderInitialized()) {
359+
try {
360+
String id = null;
361+
JQueryObject jsslider = $(jqSlider);
362+
/**
363+
* @j2sNative
364+
*
365+
*
366+
* id = this.jqSlider.id; jsslider.j2sslider("option",key,val);
367+
*/
368+
} catch (Throwable t) {
369+
// System.out.println(key + ":" + val + " could not be set for " + id);
370+
// ignore -- disposal problem?
371+
}
372+
noSnapping = isScrollBar;
373+
} else {
374+
noSnapping = true;
370375
}
371-
noSnapping = isScrollBar;
372376
}
373377

374378
private boolean sliderInitialized() {
375-
return ($data(jqSlider, "ui-j2sslider") != null);
379+
return (jqSlider != null && jquery.data(jqSlider, "ui-j2sslider") != null);
376380
}
377381

378382
public void setSlider() {

0 commit comments

Comments
 (0)