提交 950c342e 编写于 作者: A ant

8015454: java/awt/Focus/TypeAhead/TestFocusFreeze.java hangs with jdk8 since b56

Reviewed-by: anthony
上级 0938b19d
...@@ -285,10 +285,17 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { ...@@ -285,10 +285,17 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
TimedWindowEvent we = (TimedWindowEvent)e; TimedWindowEvent we = (TimedWindowEvent)e;
long time = we.getWhen(); long time = we.getWhen();
synchronized (this) { synchronized (this) {
for (KeyEvent ke: enqueuedKeyEvents) { KeyEvent ke = enqueuedKeyEvents.isEmpty() ? null : enqueuedKeyEvents.getFirst();
if (time >= ke.getWhen()) { if (ke != null && time >= ke.getWhen()) {
SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e)); TypeAheadMarker marker = typeAheadMarkers.getFirst();
return true; if (marker != null) {
Window toplevel = marker.untilFocused.getContainingWindow();
// Check that the component awaiting focus belongs to
// the current focused window. See 8015454.
if (toplevel != null && toplevel.isFocused()) {
SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e));
return true;
}
} }
} }
} }
......
...@@ -132,6 +132,7 @@ class TestKFM extends DefaultKeyboardFocusManager { ...@@ -132,6 +132,7 @@ class TestKFM extends DefaultKeyboardFocusManager {
} }
protected synchronized void enqueueKeyEvents(long after, Component untilFocused) { protected synchronized void enqueueKeyEvents(long after, Component untilFocused) {
super.enqueueKeyEvents(after, untilFocused); super.enqueueKeyEvents(after, untilFocused);
robot.delay(1);
robot.keyPress(KeyEvent.VK_SPACE); robot.keyPress(KeyEvent.VK_SPACE);
robot.delay(50); robot.delay(50);
robot.keyRelease(KeyEvent.VK_SPACE); robot.keyRelease(KeyEvent.VK_SPACE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册