Skip to content

Commit fa043ec

Browse files
hansonrhansonr
authored andcommitted
various fixes for AWT Canvas, Choice, ScrollPane,
1 parent 57de48b commit fa043ec

File tree

14 files changed

+44
-14
lines changed

14 files changed

+44
-14
lines changed
235 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190828094643
1+
20190828180221
235 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190828094643
1+
20190828180221
235 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/javax/swing/DefaultComboBoxModel.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,27 @@ public int getIndexOf(Object anObject) {
134134
}
135135

136136
// implements javax.swing.MutableComboBoxModel
137-
@Override
137+
@Override
138138
public void addElement(E anObject) {
139139
objects.addElement(anObject);
140140
fireIntervalAdded(this,objects.size()-1, objects.size()-1);
141-
if ( objects.size() == 1 && selectedObject == null && anObject != null ) {
141+
if (objects.size() == 1 && selectedObject == null && anObject != null ) {
142142
秘setSelectedItemQuiet(anObject);
143143
}
144144
}
145145

146146

147147
// implements javax.swing.MutableComboBoxModel
148-
@Override
148+
@SuppressWarnings("unused")
149+
@Override
149150
public void insertElementAt(E anObject,int index) {
150151
objects.insertElementAt(anObject,index);
151152
fireIntervalAdded(this, index, index);
153+
boolean select = (/**@j2sNative 1 ? !!this.isAWT$ : */false) ;
154+
if ( select
155+
156+
&& index == 0 && objects.size() == 1 && selectedObject == null && anObject != null )
157+
秘setSelectedItemQuiet(anObject);
152158
}
153159

154160
// implements javax.swing.MutableComboBoxModel

sources/net.sf.j2s.java.core/src/swingjs/a2s/Canvas.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public Canvas(GraphicsConfiguration config) {
1313

1414
public Canvas() {
1515
super();
16+
//no: AWT canvases are not opaque xxxsetBackground(Color.white);
1617
秘setPaintsSelf(PAINTS_SELF_ALWAYS);
1718
秘paintClass = 秘updateClass = /**@j2sNative C$ || */null;
1819
}

sources/net.sf.j2s.java.core/src/swingjs/a2s/PopupMenu.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*/
2020
public class PopupMenu extends JPopupMenu implements AWTPopupMenu {
2121

22+
public void isAWT() {}
23+
2224
public PopupMenu() {
2325
this(null);
2426
}
@@ -30,11 +32,10 @@ public PopupMenu(String string) {
3032
@Override
3133
public Font getFont() {
3234
// AWT default fonts are set by the peer (native OS)
33-
Font f = super.getFont();
34-
if (f == null) {
35-
setFont(f = new Font(Font.DIALOG, Font.PLAIN, 12));
36-
}
37-
return f;
35+
if (font == null && parent == null)
36+
font = new Font(Font.DIALOG, Font.PLAIN, 12);
37+
return super.getFont();
38+
3839
}
3940
@Override
4041
public int countItems() {

sources/net.sf.j2s.java.core/src/swingjs/a2s/ScrollPane.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ public ScrollPane(int scrollbars) {
5656
case SCROLLBARS_AS_NEEDED:
5757
break;
5858
}
59-
setBackground(Color.LIGHT_GRAY); // fills in around the scrollbars
59+
// setBackground(Color.LIGHT_GRAY); // fills in around the scrollbars
6060
setOpaque(true);
6161
}
6262

6363
@Override
6464
public Component add(Component c) {
6565
getViewport().add(c);
66+
if (!isBackgroundSet() && c.isBackgroundSet())
67+
setBackground(c.getBackground());
6668
return c;
6769
}
6870

sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sComboBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $( function() {
1616
+'\n.j2scb-unsel {background-color:white;}'
1717
+'\n.j2scb-hov {background-color:lightblue;}'
1818
+'\n.j2scbcont {position:absolute; left:0px;top:0px;}'
19-
+'\n.j2scbhead {position:absolute; left:0px;top:0px;text-align:left;overflow:hidden;}'
19+
+'\n.j2scbhead {position:absolute; left:0px;top:0px;text-align:left;overflow:hidden;padding:1px}'
2020
+'\n.j2scbbtn {position:absolute; leftbackground-color:white;:100px;top:0px; width:20px;text-align:center;cursor:pointer;background-color:lightblue;padding:0px}'
2121
+'\n.j2scbpopup {position:absolute; list-style:none}'
2222
+'\n.j2scblist {background-color:white;position:absolute; left:0px;top:0px;margin:0;border:black solid 1px;cursor:pointer;text-align:left;padding:0em;scrollbar-width:thin;cursor:pointer;}</style>'

0 commit comments

Comments
 (0)