src/share/classes/java/awt/EventQueue.java

Print this page

        

@@ -161,10 +161,15 @@
     /*
      * The time stamp of the last dispatched InputEvent or ActionEvent.
      */
     private long mostRecentEventTime = System.currentTimeMillis();
 
+    /*
+     * The time stamp of the last KeyEvent .
+     */
+    private long mostRecentKeyEventTime = System.currentTimeMillis();
+
     /**
      * The modifiers field of the current event, if the current event is an
      * InputEvent or ActionEvent.
      */
     private WeakReference currentEvent;

@@ -1136,10 +1141,19 @@
         } finally {
             pushPopLock.unlock();
         }
     }
 
+    synchronized long getMostRecentKeyEventTime() {
+        pushPopLock.lock();
+        try {
+            return mostRecentKeyEventTime;
+        } finally {
+            pushPopLock.unlock();
+        }
+    }
+
     static void setCurrentEventAndMostRecentTime(AWTEvent e) {
         Toolkit.getEventQueue().setCurrentEventAndMostRecentTimeImpl(e);
     }
     private void setCurrentEventAndMostRecentTimeImpl(AWTEvent e) {
         pushPopLock.lock();

@@ -1160,10 +1174,13 @@
             // will no longer be an issue.
             long mostRecentEventTime2 = Long.MIN_VALUE;
             if (e instanceof InputEvent) {
                 InputEvent ie = (InputEvent)e;
                 mostRecentEventTime2 = ie.getWhen();
+                if (e instanceof KeyEvent) {
+                    mostRecentKeyEventTime = ie.getWhen();
+                }
             } else if (e instanceof InputMethodEvent) {
                 InputMethodEvent ime = (InputMethodEvent)e;
                 mostRecentEventTime2 = ime.getWhen();
             } else if (e instanceof ActionEvent) {
                 ActionEvent ae = (ActionEvent)e;