This discussion is archived
1 Reply Latest reply: Oct 4, 2009 8:13 AM by 843807 RSS

writing function to print limited time

843807 Newbie
Currently Being Moderated
Hai sir,this is surendra i developed a software for online examination i have problem with printing the limited time can yoiu give the code of th function to print the limited time from the bean
  • 1. Re: writing function to print limited time
    843807 Newbie
    Currently Being Moderated
    if you are using SWING all you have to do is set up a Timer (javax.swing.Timer) and check the time each time it fires.

    in your constructor get a reference to the Calendar object:
    Calendar c = Calendar.getInstance();
    when you start your timed event:
    long myStartTime = c.getTimeInMillis();
    myTimer.start();
    when you want to check--each time the timer object fires (in the actionPerformed of your ActionListener for the Timer)
    if(myTimeInMillis()>(c.getTimeInMillis()-myStartTime)){
      //your make it exit code goes here
    }