Skip to content

Commit 61318bb

Browse files
hansonrhansonr
authored andcommitted
"isFocusable()" only activated by setFocusable(), not by default
focusable = true
1 parent 1d9c131 commit 61318bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ public AppContext getAppContext() {
358358
*/
359359
private int isFocusTraversableOverridden = FOCUS_TRAVERSABLE_UNKNOWN;
360360

361+
protected boolean _isFocusableSet; // SwingJS added
362+
361363
/**
362364
* The focus traversal keys. These keys will generate focus traversal behavior
363365
* for Components for which focus traversal keys are enabled. If a value of null
@@ -5400,7 +5402,7 @@ protected void processFocusEvent(FocusEvent e) {
54005402
*/
54015403
protected void processKeyEvent(KeyEvent e) {
54025404
KeyListener listener = keyListener;
5403-
if (listener != null) {
5405+
if (listener != null && (/** @j2sNative this.isAWT$ || */ _isFocusableSet)) {
54045406
int id = e.getID();
54055407
switch (id) {
54065408
case KeyEvent.KEY_TYPED:
@@ -6049,6 +6051,8 @@ public void setFocusable(boolean focusable) {
60496051
this.focusable = focusable;
60506052
}
60516053
isFocusTraversableOverridden = FOCUS_TRAVERSABLE_SET;
6054+
6055+
_isFocusableSet = true;
60526056

60536057
firePropertyChange("focusable", Boolean.valueOf(oldFocusable), Boolean.valueOf(focusable));
60546058
if (oldFocusable && !focusable) {

0 commit comments

Comments
 (0)