--- old/src/share/classes/java/awt/event/InputMethodEvent.java 2014-06-06 14:14:33.000000000 +0400 +++ new/src/share/classes/java/awt/event/InputMethodEvent.java 2014-06-06 14:14:33.000000000 +0400 @@ -25,6 +25,10 @@ package java.awt.event; +import sun.awt.AWTAccessor; +import sun.awt.AppContext; +import sun.awt.SunToolkit; + import java.awt.AWTEvent; import java.awt.Component; import java.awt.EventQueue; @@ -217,8 +221,10 @@ public InputMethodEvent(Component source, int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) { - this(source, id, EventQueue.getMostRecentEventTime(), text, - committedCharacterCount, caret, visiblePosition); + this(source, id, + getMostRecentEventTimeForTarget(source), + text, committedCharacterCount, + caret, visiblePosition); } /** @@ -258,8 +264,9 @@ */ public InputMethodEvent(Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition) { - this(source, id, EventQueue.getMostRecentEventTime(), null, - 0, caret, visiblePosition); + this(source, id, + getMostRecentEventTimeForTarget(source), + null, 0, caret, visiblePosition); } /** @@ -411,7 +418,20 @@ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); if (when == 0) { - when = EventQueue.getMostRecentEventTime(); + when = getMostRecentEventTimeForTarget(this.source); } } + + /** + * Get the most recent event time in the {@code EventQueue} which the {@code target} + * belongs to. + * + * @param target the target to find an {@code EventQueue} + * @return most recent event time in the {@code EventQueue} + */ + private static long getMostRecentEventTimeForTarget(Object target) { + AppContext appContext = SunToolkit.targetToAppContext(target); + EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext); + return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue); + } }