Skip to content

Commit a4b0505

Browse files
hansonrhansonr
authored andcommitted
fixing cross-applet messaging
1 parent a48900c commit a4b0505

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

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

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.ListIterator;
3737
import java.util.Set;
3838

39+
import javax.swing.JApplet;
3940
import javax.swing.JComponent;
4041
import javax.swing.SwingUtilities;
4142

@@ -111,8 +112,19 @@ public String toString() {
111112
}
112113
}
113114

115+
/**
116+
* SwingJS treats JApplet as a window. I know... just how it is.
117+
*
118+
* @param window
119+
* @return
120+
*/
114121
private Window getOwningFrameDialog(Window window) {
115-
while (window != null && !(window instanceof JSFrame || window instanceof JSDialog)) {
122+
@SuppressWarnings("unused")
123+
Object owindow;
124+
while (window != null && !(
125+
(owindow = window) instanceof JApplet
126+
|| window instanceof JSFrame
127+
|| window instanceof JSDialog)) {
116128
window = (Window) window.getParent();
117129
}
118130
return window;
@@ -238,25 +250,27 @@ static boolean sendMessage(Component target, AWTEvent e) {
238250
if (targetAppContext.isDisposed()) {
239251
return false;
240252
}
241-
SunToolkit.postEvent(targetAppContext, se);
242-
if (EventQueue.isDispatchThread()) {
243-
EventDispatchThread edt = (EventDispatchThread) Thread.currentThread();
244-
edt.pumpEvents(SentEvent.ID, new Conditional() {
245-
public boolean evaluate() {
246-
return !se.dispatched && !targetAppContext.isDisposed();
247-
}
248-
});
249-
} else {
250-
synchronized (se) {
251-
while (!se.dispatched && !targetAppContext.isDisposed()) {
252-
try {
253-
se.wait(1000);
254-
} catch (InterruptedException ie) {
255-
break;
256-
}
257-
}
258-
}
259-
}
253+
// SwingJS - do we care?
254+
se.dispatch();
255+
// SunToolkit.postEvent(targetAppContext, se);
256+
// if (EventQueue.isDispatchThread()) {
257+
// EventDispatchThread edt = (EventDispatchThread) Thread.currentThread();
258+
// edt.pumpEvents(SentEvent.ID, new Conditional() {
259+
// public boolean evaluate() {
260+
// return !se.dispatched && !targetAppContext.isDisposed();
261+
// }
262+
// });
263+
// } else {
264+
// synchronized (se) {
265+
// while (!se.dispatched && !targetAppContext.isDisposed()) {
266+
// try {
267+
// se.wait(1000);
268+
// } catch (InterruptedException ie) {
269+
// break;
270+
// }
271+
// }
272+
// }
273+
// }
260274
}
261275
return se.dispatched;
262276
}

0 commit comments

Comments
 (0)