Skip to content

Commit 6dc52cf

Browse files
hansonrhansonr
authored andcommitted
fixing AWT defaults
1 parent 4f3929c commit 6dc52cf

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ public void installUI(JComponent jc) {
5353
}
5454

5555
@Override
56-
boolean handleEnter(int eventType) {
57-
if (eventType == SOME_KEY_EVENT) {
58-
Action a = getActionMap().get(JTextField.notifyAction);
59-
if (a != null) {
60-
JSToolkit.setIsDispatchThread(true);
61-
a.actionPerformed(new ActionEvent(c, ActionEvent.ACTION_PERFORMED,
62-
JTextField.notifyAction, System.currentTimeMillis(), 0));
63-
JSToolkit.setIsDispatchThread(false);
64-
}
56+
boolean handleEnter() {
57+
Action a = getActionMap().get(JTextField.notifyAction);
58+
if (a != null) {
59+
JSToolkit.setIsDispatchThread(true);
60+
a.actionPerformed(new ActionEvent(c, ActionEvent.ACTION_PERFORMED,
61+
JTextField.notifyAction, System.currentTimeMillis(), 0));
62+
JSToolkit.setIsDispatchThread(false);
6563
}
6664
return true;
6765
}

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

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public abstract class JSTextUI extends JSLightweightUI {// implements {ViewFacto
129129
@Override
130130
public DOMNode updateDOMNode() {
131131
if (editor.isOpaque() && editor.isEnabled())
132-
setBackground(editor.getBackground());
132+
setBackgroundCUI(getBackground());
133133
setEditable(editable);
134134
return updateDOMNodeCUI();
135135
}
@@ -169,14 +169,32 @@ protected void installDefaults() {
169169
editor.setFont(UIManager.getFont(prefix + ".font"));
170170
}
171171

172+
setColors(prefix);
173+
//
174+
// Border b = editor.getBorder();
175+
// if ((b == null) || (b instanceof UIResource)) {
176+
// editor.setBorder(UIManager.getBorder(prefix + ".border"));
177+
// }
178+
//
179+
Insets margin = editor.getMargin();
180+
if (margin == null || margin instanceof UIResource) {
181+
editor.setMargin(UIManager.getInsets(prefix + ".margin"));
182+
}
183+
//
184+
// updateCursor();
185+
}
186+
187+
protected void setColors(String prefix) {
172188
Color bg = editor.getBackground();
173189
if ((bg == null) || (bg instanceof UIResource)) {
174190
editor.setBackground(UIManager.getColor(prefix + ".background"));
175191
}
176192

177-
Color fg = editor.getForeground();
178-
if ((fg == null) || (fg instanceof UIResource)) {
179-
editor.setForeground(UIManager.getColor(prefix + ".foreground"));
193+
if (!isAWT) {
194+
Color fg = editor.getForeground();
195+
if ((fg == null) || (fg instanceof UIResource)) {
196+
editor.setForeground(UIManager.getColor(prefix + ".foreground"));
197+
}
180198
}
181199
//
182200
// Color color = editor.getCaretColor();
@@ -198,27 +216,16 @@ protected void installDefaults() {
198216
//
199217
Color dfg = editor.getDisabledTextColor();
200218
if ((dfg == null) || (dfg instanceof UIResource)) {
201-
editor.setDisabledTextColor(UIManager.getColor(prefix
202-
+ ".inactiveForeground"));
219+
editor.setDisabledTextColor(UIManager.getColor(prefix + ".inactiveForeground"));
203220
}
204221
dfg = UIManager.getColor(prefix + ".inactiveBackground");
205222
if (dfg != null)
206223
inactiveBackground = dfg;
207224

208-
//
209-
// Border b = editor.getBorder();
210-
// if ((b == null) || (b instanceof UIResource)) {
211-
// editor.setBorder(UIManager.getBorder(prefix + ".border"));
212-
// }
213-
//
214-
Insets margin = editor.getMargin();
215-
if (margin == null || margin instanceof UIResource) {
216-
editor.setMargin(UIManager.getInsets(prefix + ".margin"));
217-
}
218-
//
219-
// updateCursor();
220225
}
221226

227+
228+
222229
protected void installDefaults2() {
223230
// editor.addMouseListener(dragListener);
224231
// editor.addMouseMotionListener(dragListener);
@@ -2042,7 +2049,7 @@ public boolean isEnabled() {
20422049
}
20432050
}
20442051

2045-
boolean handleEnter(int eventType) {
2052+
boolean handleEnter() {
20462053
return false;
20472054
}
20482055

@@ -2052,8 +2059,8 @@ public void setEditable(boolean editable) {
20522059
return;
20532060
setEditableCSS();
20542061
if (jc.isOpaque()) {
2055-
Color bg = c.getBackground();
2056-
setBackground(editable || !(bg instanceof UIResource) || inactiveBackground == null ? bg : inactiveBackground);
2062+
Color bg = getBackground();
2063+
setBackgroundCUI(editable || !(bg instanceof UIResource) || inactiveBackground == null ? bg : inactiveBackground);
20572064
}
20582065
}
20592066

0 commit comments

Comments
 (0)