src/share/classes/java/awt/event/InputMethodEvent.java

Print this page

        

*** 23,32 **** --- 23,36 ---- * questions. */ 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; import java.awt.font.TextHitInfo; import java.io.IOException;
*** 215,226 **** * @throws IllegalArgumentException if <code>source</code> is null */ public InputMethodEvent(Component source, int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) { ! this(source, id, EventQueue.getMostRecentEventTime(), text, ! committedCharacterCount, caret, visiblePosition); } /** * Constructs an <code>InputMethodEvent</code> with the * specified source component, type, caret, and visiblePosition. --- 219,232 ---- * @throws IllegalArgumentException if <code>source</code> is null */ public InputMethodEvent(Component source, int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) { ! this(source, id, ! getMostRecentEventTimeForTarget(source), ! text, committedCharacterCount, ! caret, visiblePosition); } /** * Constructs an <code>InputMethodEvent</code> with the * specified source component, type, caret, and visiblePosition.
*** 256,267 **** * <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code> * @throws IllegalArgumentException if <code>source</code> is null */ public InputMethodEvent(Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition) { ! this(source, id, EventQueue.getMostRecentEventTime(), null, ! 0, caret, visiblePosition); } /** * Gets the combined committed and composed text. * Characters from index 0 to index <code>getCommittedCharacterCount() - 1</code> are committed --- 262,274 ---- * <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code> * @throws IllegalArgumentException if <code>source</code> is null */ public InputMethodEvent(Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition) { ! this(source, id, ! getMostRecentEventTimeForTarget(source), ! null, 0, caret, visiblePosition); } /** * Gets the combined committed and composed text. * Characters from index 0 to index <code>getCommittedCharacterCount() - 1</code> are committed
*** 409,417 **** * invoking {@link java.awt.EventQueue#getMostRecentEventTime()}. */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); if (when == 0) { ! when = EventQueue.getMostRecentEventTime(); } } } --- 416,437 ---- * invoking {@link java.awt.EventQueue#getMostRecentEventTime()}. */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); if (when == 0) { ! 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); } }