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

At times getWhen()in ActionEvent returns higher value than the CurrentSystemTime

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 6
    • Fix Version/s: 7
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description

      =========================================================
      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b82)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b82, mixed mode)

      Platforms : Windows , Solaris IA .

      ====================================================

      I understand that getWhen() method in ActionEvent should always return a value that is lesser than the current System time .Correct me If I am wrong ?

      Now when I run this test program , I observe that getWhen() sometimes returns a time that is higher than the current system time .

      ===================================================

      Steps to reproduce this program :

      1) Run this program .

      2) when the frame comes up , Click on the Button .An action Event will be triggered and I am printing the values returned by getWhen() and
      the Current System time to the console.

      3) Click the Button 10 -15 times , you will observe that at some instants , the value returned by getWhen() is much higher than the
      current system time .(which should not be the case )


      Test Program :
      ===========================================================

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

      public class ActionEventTest extends Frame implements ActionListener{

              Frame frame;
              Button button;
              TextField textField;
              Toolkit toolkit ;

          public ActionEventTest() {

              frame=new Frame();
              frame.setTitle("Action Event Test");
              frame.setLayout(new FlowLayout());

              button=new Button("BUTTON");
              textField=new TextField(5);

              button.addActionListener(this);
      textField.addActionListener(this);

              frame.add(button);
              frame.add(textField);

              frame.setBackground(Color.red);
              frame.setSize(500,200);
              frame.setVisible(true);
              frame.toFront();
          }

          public void actionPerformed(ActionEvent ae) {


      long when = ae.getWhen();
              long current = System.currentTimeMillis();
              System.out.println("getWhen returns :"+ when);
              System.out.println("current returns :"+ current);
              if(when < current){
                System.out.println("getWhen is lesser than Current time ");
              }
              if(when >= current){
                System.out.println("getWhen is greater than Current time ");
              }
              System.out.println("Param String is : " + ae.paramString());
      System.out.println("********************************");

          }

      public static void main(String args[]){
        ActionEventTest avt = new ActionEventTest();

      }
      }

      ========================================================================


      Note : This bug is not easily reproducable and you will have to click the button
       10 -15 times . This is easily reproducable in Windows/IA for a few clicks .

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ant Anton Tarasov
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: