Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4176525

InputEvent.getWhen() returns with wrong event's timestamp

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2.2
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description

      When calling getWhen() method it returns the wrong time. Look at times below.

      Current Time = Fri Sep 25 16:06:16 EDT 1998
      GetWhen Time = Tue Jan 06 18:17:56 EST 1970


      Test Case:

      ***** Main.java *****

      import java.awt.*;
      import java.awt.event.*;
      import java.util.*;

      public class Main extends Frame {

        public Main() {
          setTitle("getWhen Example");
          setSize(500,100);
          this.enableEvents(AWTEvent.MOUSE_EVENT_MASK);
          setVisible(true);
        }

        protected void processEvent(AWTEvent evt) {

          if (evt instanceof InputEvent) {
            long currentTime = (new Date()).getTime();
            long eventTime = ((InputEvent)evt).getWhen();

            System.out.println("Current Time = " + new Date(currentTime));
            System.out.println("GetWhen Time = " + new Date(eventTime));
          }
        }

        public static void main (String args[]) {
          new Main();
        }
      }

        Attachments

          Activity

            People

            • Assignee:
              ehawkessunw Eric Hawkes (Inactive)
              Reporter:
              collins Gary Collins (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: