Skip to content

Commit 974e726

Browse files
committed
JSComboPopupList UI issues.
1 parent 29b4c2f commit 974e726

File tree

9 files changed

+140
-83
lines changed

9 files changed

+140
-83
lines changed
937 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220316050605
1+
20220329063442
937 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220316050605
1+
20220329063442
832 Bytes
Binary file not shown.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ private DOMNode renderItem(int i, int w, JSListUI ui) {
169169
JComponent j = (JComponent) cbui.comboBox.getRenderer().getListCellRendererComponent(this,
170170
getModel().getElementAt(i), i, true, false);
171171
j.setSize(w, ui.getRowHeight(i));
172-
return j.秘getUI().getListNode();
172+
JSComponentUI jui = j.秘getUI();
173+
jui.c = jui.jc = j;
174+
return jui.getListNode();
173175
}
174176

175177
void updateSelectedIndex() {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public void paint(Graphics g, JComponent c) {
112112

113113
@Override
114114
public Dimension getPreferredSize(JComponent jc) {
115+
c = this.jc = jc; // renderer issue
115116
updateDOMNode();
116117
return (isAWT ? getMinimumSizePeer(jc, label)
117118
: label == null ? super.getPreferredSize(jc)

sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
// Google closure compiler cannot handle Clazz.new or Clazz.super
99

10+
// BH 2022.03.19 String.valueOf(Double) does not add ".0"
1011
// BH 2022.01.17 fixes interface default method referencing own static fields
1112
// BH 2021.12.19 adds Double -0; fixes println(Double)
1213
// BH 2021.12.15 default encoding for String.getBytes() should be utf-8.
@@ -102,7 +103,10 @@ Clazz.array = function(baseClass, paramType, ndims, params, isClone) {
102103

103104
var _array = function(baseClass, paramType, ndims, params, isClone) {
104105

106+
// Object x = Array.newInstance(componentClass, nElements);
107+
// var x=Clazz.array((Clazz.array(componentClass, 3);
105108

109+
106110
// int[][].class Clazz.array(Integer.TYPE, -2)
107111
// new int[] {3, 4, 5} Clazz.array(Integer.TYPE, -1, [3, 4, 5])
108112
// new int[][]{new int[] {3, 4, 5}, {new int[] {3, 4, 5}}
@@ -151,8 +155,26 @@ var _array = function(baseClass, paramType, ndims, params, isClone) {
151155
// new int[] {3, 4, 5};
152156
return _array(baseClass, prim + "A", -1, vals);
153157
}
154-
// Array.newInstance(int[][].class, 3);
155-
return _array(baseClass, prim + "A", (cl.__NDIM || 0) + 1, [ndims]);
158+
// Array.newInstance(int[][].class, 3);
159+
160+
161+
var nElem = ndims;
162+
cl = baseClass;
163+
164+
ndims = 0;
165+
while ((cl = cl.getComponentType$()) != null) {
166+
baseClass = cl;
167+
ndims++;
168+
}
169+
if (ndims > 0) {
170+
a = new Array(nElem);
171+
setArray(a, baseClass, prim + "A", ndims + 1);
172+
for (var i = nElem; --i >= 0;)
173+
a[i] = null;
174+
} else {
175+
a = _array(baseClass, prim + "A", ndims + 1, [nElem]);
176+
}
177+
return a;
156178
}
157179
params = vals;
158180
paramType = prim;
@@ -174,22 +196,7 @@ var _array = function(baseClass, paramType, ndims, params, isClone) {
174196
} else {
175197
var initValue = null;
176198
if (ndims >= 1 && dofill) {
177-
switch (prim) {
178-
case "J":
179-
case "B":
180-
case "H": // short
181-
case "I":
182-
case "F":
183-
case "D":
184-
initValue = 0;
185-
break;
186-
case "C":
187-
initValue = '\0';
188-
break;
189-
case "Z":
190-
initValue = false;
191-
break;
192-
}
199+
initValue = _initVal(prim);
193200
}
194201
var p = params; // an Int32Array
195202
var n = p.length;
@@ -221,6 +228,24 @@ var _array = function(baseClass, paramType, ndims, params, isClone) {
221228
return newTypedA(baseClass, params, nbits, (dofill ? ndims : -ndims), isClone);
222229
}
223230

231+
var _initVal = function(p) {
232+
switch (p) {
233+
case "J":
234+
case "B":
235+
case "H": // short
236+
case "I":
237+
case "F":
238+
case "D":
239+
return 0;
240+
case "C":
241+
return '\0';
242+
case "Z":
243+
return false;
244+
default:
245+
return null;
246+
}
247+
}
248+
224249
Clazz.assert = function(clazz, obj, tf, msg) {
225250
if (!clazz.$_ASSERT_ENABLED_)return;
226251
var ok = true;
@@ -3244,52 +3269,54 @@ Sys.err = new Clazz._O ();
32443269
Sys.err.__CLASS_NAME__ = "java.io.PrintStream";
32453270

32463271
var checkTrace = function(s) {
3247-
if (J2S._nooutput || J2S._traceFilter && s.indexOf(J2S._traceFilter) < 0) return;
3248-
if (!J2S._traceFilter && J2S._traceOutput && s &&
3249-
(("" + s).indexOf(J2S._traceOutput) >= 0 || '"' + s + '"' == J2S._traceOutput)) {
3272+
if (J2S._nooutput || !J2S._traceFilter && !J2S._traceOutput) return;
3273+
if (J2S._traceFilter) {
3274+
if ((s= "" + s).indexOf(J2S._traceFilter) < 0)
3275+
return;
3276+
} else if (!(s = "" + s) || s.indexOf(J2S._traceOutput) < 0 && '"' + s + '"' != J2S._traceOutput) {
3277+
return;
3278+
}
32503279
alert(s + "\n\n" + Clazz._getStackTrace());
32513280
doDebugger();
3252-
}
32533281
}
32543282

32553283
var setps = function(ps, f) {
32563284

3257-
ps.print = ps.print$O = ps.print$Z = ps.print$I = ps.print$S = ps.print$C = function (s) {
3285+
ps.flush$ = function() {}
3286+
3287+
ps.print = ps.print$ = ps.print$O = ps.print$Z = ps.print$I = ps.print$S = ps.print$C = function (s) {
32583288
checkTrace(s);
3259-
f(s);
3289+
f("" + s);
32603290
};
32613291

32623292
ps.print$J = function(l) {ps.print(Long.$s(l))}
3293+
ps.print$F = ps.print$D = function(f) {
3294+
var s = "" + f;
3295+
ps.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s);
3296+
}
3297+
32633298
ps.printf = ps.printf$S$OA = ps.format = ps.format$S$OA = function (f, args) {
32643299
ps.print(String.format$S$OA.apply(null, arguments));
32653300
}
32663301

3267-
ps.flush$ = function() {}
3268-
3269-
ps.println = ps.println$ = ps.println$Z = ps.println$I = ps.println$S = ps.println$C = function(s) {
3270-
s = (typeof s == "undefined" ? "" : "" + s);
3302+
ps.println = ps.println$ = ps.println$Z = ps.println$I = ps.println$S = ps.println$C = ps.println$O = function(s) {
32713303
checkTrace(s);
3272-
s = (typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n");
3273-
f(s);
3304+
f((s && s.toString ? s.toString() : "" + s) + "\r\n");
32743305
};
32753306

3276-
ps.println$O = function(s) {
3277-
s = (typeof s == "undefined" ? "" : s.toString());
3278-
checkTrace(s);
3279-
s = (typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n");
3280-
f(s);
3281-
};
3282-
32833307
ps.println$J = function(l) {ps.println(Long.$s(l))}
3284-
ps.println$F = ps.println$D = function(f) {var s = "" + f; ps.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s)};
3308+
ps.println$F = ps.println$D = function(f) {
3309+
var s = "" + f;
3310+
ps.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s);
3311+
}
32853312

32863313
ps.write$I = function(ch) {
32873314
ps.print(String.fromCharCode(ch));
32883315
}
32893316

32903317
ps.write$BA = function (buf) {
32913318
ps.write$BA$I$I(buf, 0, buf.length);
3292-
};
3319+
};
32933320

32943321
ps.write$BA$I$I = function (buf, offset, len) {
32953322
ps.print(String.instantialize(buf, offset, len));
@@ -5970,7 +5997,7 @@ oo[i]=o[off+i];
59705997
return oo.join('');
59715998
}
59725999
}
5973-
return""+o;
6000+
return (o != null && o.toString ? o.toString() : ""+o);
59746001
};
59756002

59766003
sp.subSequence$I$I=function(beginIndex,endIndex){

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14039,6 +14039,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1403914039

1404014040
// Google closure compiler cannot handle Clazz.new or Clazz.super
1404114041

14042+
// BH 2022.03.19 String.valueOf(Double) does not add ".0"
1404214043
// BH 2022.01.17 fixes interface default method referencing own static fields
1404314044
// BH 2021.12.19 adds Double -0; fixes println(Double)
1404414045
// BH 2021.12.15 default encoding for String.getBytes() should be utf-8.
@@ -14134,7 +14135,10 @@ Clazz.array = function(baseClass, paramType, ndims, params, isClone) {
1413414135

1413514136
var _array = function(baseClass, paramType, ndims, params, isClone) {
1413614137

14138+
// Object x = Array.newInstance(componentClass, nElements);
14139+
// var x=Clazz.array((Clazz.array(componentClass, 3);
1413714140

14141+
1413814142
// int[][].class Clazz.array(Integer.TYPE, -2)
1413914143
// new int[] {3, 4, 5} Clazz.array(Integer.TYPE, -1, [3, 4, 5])
1414014144
// new int[][]{new int[] {3, 4, 5}, {new int[] {3, 4, 5}}
@@ -14183,8 +14187,26 @@ var _array = function(baseClass, paramType, ndims, params, isClone) {
1418314187
// new int[] {3, 4, 5};
1418414188
return _array(baseClass, prim + "A", -1, vals);
1418514189
}
14186-
// Array.newInstance(int[][].class, 3);
14187-
return _array(baseClass, prim + "A", (cl.__NDIM || 0) + 1, [ndims]);
14190+
// Array.newInstance(int[][].class, 3);
14191+
14192+
14193+
var nElem = ndims;
14194+
cl = baseClass;
14195+
14196+
ndims = 0;
14197+
while ((cl = cl.getComponentType$()) != null) {
14198+
baseClass = cl;
14199+
ndims++;
14200+
}
14201+
if (ndims > 0) {
14202+
a = new Array(nElem);
14203+
setArray(a, baseClass, prim + "A", ndims + 1);
14204+
for (var i = nElem; --i >= 0;)
14205+
a[i] = null;
14206+
} else {
14207+
a = _array(baseClass, prim + "A", ndims + 1, [nElem]);
14208+
}
14209+
return a;
1418814210
}
1418914211
params = vals;
1419014212
paramType = prim;
@@ -14206,22 +14228,7 @@ var _array = function(baseClass, paramType, ndims, params, isClone) {
1420614228
} else {
1420714229
var initValue = null;
1420814230
if (ndims >= 1 && dofill) {
14209-
switch (prim) {
14210-
case "J":
14211-
case "B":
14212-
case "H": // short
14213-
case "I":
14214-
case "F":
14215-
case "D":
14216-
initValue = 0;
14217-
break;
14218-
case "C":
14219-
initValue = '\0';
14220-
break;
14221-
case "Z":
14222-
initValue = false;
14223-
break;
14224-
}
14231+
initValue = _initVal(prim);
1422514232
}
1422614233
var p = params; // an Int32Array
1422714234
var n = p.length;
@@ -14253,6 +14260,24 @@ var _array = function(baseClass, paramType, ndims, params, isClone) {
1425314260
return newTypedA(baseClass, params, nbits, (dofill ? ndims : -ndims), isClone);
1425414261
}
1425514262

14263+
var _initVal = function(p) {
14264+
switch (p) {
14265+
case "J":
14266+
case "B":
14267+
case "H": // short
14268+
case "I":
14269+
case "F":
14270+
case "D":
14271+
return 0;
14272+
case "C":
14273+
return '\0';
14274+
case "Z":
14275+
return false;
14276+
default:
14277+
return null;
14278+
}
14279+
}
14280+
1425614281
Clazz.assert = function(clazz, obj, tf, msg) {
1425714282
if (!clazz.$_ASSERT_ENABLED_)return;
1425814283
var ok = true;
@@ -17276,52 +17301,54 @@ Sys.err = new Clazz._O ();
1727617301
Sys.err.__CLASS_NAME__ = "java.io.PrintStream";
1727717302

1727817303
var checkTrace = function(s) {
17279-
if (J2S._nooutput || J2S._traceFilter && s.indexOf(J2S._traceFilter) < 0) return;
17280-
if (!J2S._traceFilter && J2S._traceOutput && s &&
17281-
(("" + s).indexOf(J2S._traceOutput) >= 0 || '"' + s + '"' == J2S._traceOutput)) {
17304+
if (J2S._nooutput || !J2S._traceFilter && !J2S._traceOutput) return;
17305+
if (J2S._traceFilter) {
17306+
if ((s= "" + s).indexOf(J2S._traceFilter) < 0)
17307+
return;
17308+
} else if (!(s = "" + s) || s.indexOf(J2S._traceOutput) < 0 && '"' + s + '"' != J2S._traceOutput) {
17309+
return;
17310+
}
1728217311
alert(s + "\n\n" + Clazz._getStackTrace());
1728317312
doDebugger();
17284-
}
1728517313
}
1728617314

1728717315
var setps = function(ps, f) {
1728817316

17289-
ps.print = ps.print$O = ps.print$Z = ps.print$I = ps.print$S = ps.print$C = function (s) {
17317+
ps.flush$ = function() {}
17318+
17319+
ps.print = ps.print$ = ps.print$O = ps.print$Z = ps.print$I = ps.print$S = ps.print$C = function (s) {
1729017320
checkTrace(s);
17291-
f(s);
17321+
f("" + s);
1729217322
};
1729317323

1729417324
ps.print$J = function(l) {ps.print(Long.$s(l))}
17325+
ps.print$F = ps.print$D = function(f) {
17326+
var s = "" + f;
17327+
ps.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s);
17328+
}
17329+
1729517330
ps.printf = ps.printf$S$OA = ps.format = ps.format$S$OA = function (f, args) {
1729617331
ps.print(String.format$S$OA.apply(null, arguments));
1729717332
}
1729817333

17299-
ps.flush$ = function() {}
17300-
17301-
ps.println = ps.println$ = ps.println$Z = ps.println$I = ps.println$S = ps.println$C = function(s) {
17302-
s = (typeof s == "undefined" ? "" : "" + s);
17334+
ps.println = ps.println$ = ps.println$Z = ps.println$I = ps.println$S = ps.println$C = ps.println$O = function(s) {
1730317335
checkTrace(s);
17304-
s = (typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n");
17305-
f(s);
17336+
f((s && s.toString ? s.toString() : "" + s) + "\r\n");
1730617337
};
1730717338

17308-
ps.println$O = function(s) {
17309-
s = (typeof s == "undefined" ? "" : s.toString());
17310-
checkTrace(s);
17311-
s = (typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n");
17312-
f(s);
17313-
};
17314-
1731517339
ps.println$J = function(l) {ps.println(Long.$s(l))}
17316-
ps.println$F = ps.println$D = function(f) {var s = "" + f; ps.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s)};
17340+
ps.println$F = ps.println$D = function(f) {
17341+
var s = "" + f;
17342+
ps.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s);
17343+
}
1731717344

1731817345
ps.write$I = function(ch) {
1731917346
ps.print(String.fromCharCode(ch));
1732017347
}
1732117348

1732217349
ps.write$BA = function (buf) {
1732317350
ps.write$BA$I$I(buf, 0, buf.length);
17324-
};
17351+
};
1732517352

1732617353
ps.write$BA$I$I = function (buf, offset, len) {
1732717354
ps.print(String.instantialize(buf, offset, len));
@@ -20002,7 +20029,7 @@ oo[i]=o[off+i];
2000220029
return oo.join('');
2000320030
}
2000420031
}
20005-
return""+o;
20032+
return (o != null && o.toString ? o.toString() : ""+o);
2000620033
};
2000720034

2000820035
sp.subSequence$I$I=function(beginIndex,endIndex){

0 commit comments

Comments
 (0)