Skip to content

Commit 6448ca7

Browse files
committed
List fix for AWT not updating scrollbar and not wrapped properly
1 parent b3b1e96 commit 6448ca7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,8 @@ protected void addImpl(Component comp, Object constraints, int index) {
10811081
protected void addImplCont(Component comp, Object constraints, int index) {
10821082
synchronized (getTreeLock()) {
10831083

1084-
if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
1084+
// AWT a2s.List alone right now has getWrap
1085+
if (/** @j2sNative comp.秘getWrap$ && !this.秘isWrapper$ || */ false) {
10851086
comp = ((A2SWrappedComponent) comp).秘getWrap();
10861087
comp.background = comp.foreground = null; // this parent should not set the background color
10871088
}
@@ -1262,7 +1263,7 @@ public void remove(int index) {
12621263
public void remove(Component comp) {
12631264
synchronized (getTreeLock()) {
12641265

1265-
if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
1266+
if (/** @j2sNative comp.秘getWrap$ && !this.秘isWrapper$ || */ false) {
12661267
comp = ((A2SWrappedComponent) comp).秘getWrap();
12671268
}
12681269

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ protected void fillDOM() {
240240
*/
241241
boolean isLeftToRight = true;
242242

243+
private boolean awtScrollPaneNeedsLayout;
244+
243245
/*
244246
* The bits below define JList property changes that affect layout. When one
245247
* of these properties changes we set a bit in updateLayoutStateNeeded. The
@@ -399,7 +401,6 @@ public void paint(Graphics g, JComponent c) {
399401
}
400402

401403
private void paintImpl(Graphics g, JComponent c) {
402-
403404
// It is the responsibility of the JScrollPane scrollbar will move the JList
404405
// to new x,y coordinates.
405406

@@ -431,7 +432,6 @@ private void paintImpl(Graphics g, JComponent c) {
431432
if ((renderer == null) || (size = dataModel.getSize()) == 0) {
432433
return;
433434
}
434-
435435
// Determine how many columns we need to paint
436436
Rectangle paintBounds = g.getClipBounds();
437437
int startColumn, endColumn;
@@ -477,6 +477,12 @@ private void paintImpl(Graphics g, JComponent c) {
477477
rendererPane.removeAll();
478478
// no -- this will paint the background over the painted backgrounds
479479
// updateDOMNode();
480+
if (awtScrollPaneNeedsLayout) {
481+
awtScrollPaneNeedsLayout = false;
482+
scrollPaneUI.jc.layout();
483+
}
484+
485+
480486
}
481487

482488
// private void paintDropLine(Graphics g) {
@@ -1422,6 +1428,8 @@ int convertModelToColumn(int index) {
14221428
*/
14231429
protected void maybeUpdateLayoutState() {
14241430
if (updateLayoutStateNeeded != 0) {
1431+
if (isAWT && scrollPaneUI != null)
1432+
awtScrollPaneNeedsLayout = true;
14251433
updateLayoutStateNeeded = 0; // SwingJS switch of order here for getting
14261434
// actual size
14271435
updateLayoutState();

0 commit comments

Comments
 (0)