Skip to content

Commit 43f0a74

Browse files
hansonrhansonr
authored andcommitted
AWT List background and selection fix
1 parent 2df44f1 commit 43f0a74

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed
-36 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190319215915
1+
20190320154313
-36 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190319215915
1+
20190320154313
-36 Bytes
Binary file not shown.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ protected void addImplCont(Component comp, Object constraints, int index) {
10761076

10771077
if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
10781078
comp = ((A2SWrappedComponent) comp).getWrap$();
1079+
comp.background = comp.foreground = null; // this parent should not set the background color
10791080
}
10801081
// SwingJS used for all add methods
10811082

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,9 +1168,7 @@ public void propertyChange(PropertyChangeEvent e) {
11681168
}
11691169

11701170
private Container awttop;
1171-
protected Color awtPeerBG;
1172-
1173-
private Color awtPeerFG;
1171+
protected Color awtPeerBG, awtPeerFG;
11741172

11751173
/**
11761174
* AWT component background, foreground, and font are all set at the

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,7 +2680,9 @@ public void valueChanged(ListSelectionEvent e) {
26802680
int lastIndex = Math.min(size - 1, Math.max(e.getLastIndex(), 0));
26812681

26822682
Rectangle bounds = getCellBounds(list, firstIndex, lastIndex);
2683-
2683+
list.ensureIndexIsVisible(firstIndex);
2684+
if (lastIndex != firstIndex)
2685+
list.ensureIndexIsVisible(lastIndex);
26842686
if (bounds != null) {
26852687
list.repaint(bounds.x, bounds.y, bounds.width, bounds.height);
26862688
}
@@ -2946,38 +2948,36 @@ static int adjustIndex(int index, JList list) {
29462948
// ListPeer
29472949

29482950
public void makeVisible(int index) {
2949-
System.out.println("JSListUI makeVisible "+ index);
2950-
2951-
2951+
// System.out.println("JSListUI makeVisible "+ index);
29522952
}
29532953

29542954
public int[] getSelectedIndexes() {
2955-
System.out.println("JSListUI getselected");
2955+
// System.out.println("JSListUI getselected");
29562956
return new int[] {};
29572957
}
29582958

29592959
public void add(String item, int index) {
2960-
System.out.println("JSListUI add item " + item + " at "+ index);
2960+
// System.out.println("JSListUI add item " + item + " at "+ index);
29612961
}
29622962

29632963
public void delItems(int start, int end) {
2964-
System.out.println("JSListUI delItems " + start + " " + end);
2964+
// System.out.println("JSListUI delItems " + start + " " + end);
29652965
}
29662966

29672967
public void removeAll() {
2968-
System.out.println("JSListUI removeAll");
2968+
// System.out.println("JSListUI removeAll");
29692969
}
29702970

29712971
public void select(int index) {
2972-
System.out.println("JSListUI select " + index);
2972+
// System.out.println("JSListUI select " + index);
29732973
}
29742974

29752975
public void deselect(int index) {
2976-
System.out.println("JSListUI deselect " + index);
2976+
// System.out.println("JSListUI deselect " + index);
29772977
}
29782978

29792979
public void setMultipleMode(boolean m) {
2980-
System.out.println("JSListUI setMultipleMode " + m);
2980+
// System.out.println("JSListUI setMultipleMode " + m);
29812981
}
29822982

29832983
/**

0 commit comments

Comments
 (0)