401 }
402
403 String visiblePositionString;
404 if (visiblePosition == null) {
405 visiblePositionString = "no visible position";
406 } else {
407 visiblePositionString = "visible position: " + visiblePosition.toString();
408 }
409
410 return typeStr + ", " + textString + ", " + countString + ", " + caretString + ", " + visiblePositionString;
411 }
412
413 /**
414 * Initializes the <code>when</code> field if it is not present in the
415 * object input stream. In that case, the field will be initialized by
416 * invoking {@link java.awt.EventQueue#getMostRecentEventTime()}.
417 */
418 private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
419 s.defaultReadObject();
420 if (when == 0) {
421 when = getMostRecentEventTimeForSource(this.source);
422 }
423 }
424
425 /**
426 * Get the most recent event time in the {@code EventQueue} which the {@code source}
427 * belongs to.
428 *
429 * @param source the source of the event
430 * @exception IllegalArgumentException if source is null.
431 * @return most recent event time in the {@code EventQueue}
432 */
433 private static long getMostRecentEventTimeForSource(Object source) {
434 if (source == null) {
435 // throw the IllegalArgumentException to conform to EventObject spec
436 throw new IllegalArgumentException("null source");
437 }
438 AppContext appContext = SunToolkit.targetToAppContext(source);
439 EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext);
440 return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue);
441 }
|
401 }
402
403 String visiblePositionString;
404 if (visiblePosition == null) {
405 visiblePositionString = "no visible position";
406 } else {
407 visiblePositionString = "visible position: " + visiblePosition.toString();
408 }
409
410 return typeStr + ", " + textString + ", " + countString + ", " + caretString + ", " + visiblePositionString;
411 }
412
413 /**
414 * Initializes the <code>when</code> field if it is not present in the
415 * object input stream. In that case, the field will be initialized by
416 * invoking {@link java.awt.EventQueue#getMostRecentEventTime()}.
417 */
418 private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
419 s.defaultReadObject();
420 if (when == 0) {
421 // Can't use getMostRecentEventTimeForSource because source is always null during deserialization
422 when = EventQueue.getMostRecentEventTime();
423 }
424 }
425
426 /**
427 * Get the most recent event time in the {@code EventQueue} which the {@code source}
428 * belongs to.
429 *
430 * @param source the source of the event
431 * @exception IllegalArgumentException if source is null.
432 * @return most recent event time in the {@code EventQueue}
433 */
434 private static long getMostRecentEventTimeForSource(Object source) {
435 if (source == null) {
436 // throw the IllegalArgumentException to conform to EventObject spec
437 throw new IllegalArgumentException("null source");
438 }
439 AppContext appContext = SunToolkit.targetToAppContext(source);
440 EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext);
441 return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue);
442 }
|