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,
! getMostRecentEventTimeForSource(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,
! getMostRecentEventTimeForSource(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,442 ----
* invoking {@link java.awt.EventQueue#getMostRecentEventTime()}.
*/
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
s.defaultReadObject();
if (when == 0) {
! when = getMostRecentEventTimeForSource(this.source);
! }
! }
!
! /**
! * Get the most recent event time in the {@code EventQueue} which the {@code source}
! * belongs to.
! *
! * @param source the source of the event
! * @exception IllegalArgumentException if source is null.
! * @return most recent event time in the {@code EventQueue}
! */
! private static long getMostRecentEventTimeForSource(Object source) {
! if (source == null) {
! // throw the IllegalArgumentException to conform to EventObject spec
! throw new IllegalArgumentException("null source");
}
+ AppContext appContext = SunToolkit.targetToAppContext(source);
+ EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext);
+ return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue);
}
}