How to use the timer control on a form.
You can run this technique code from:
NOTE First make sure that database is running on your localhost SilverStream Server | |
See the chapter on the Form Designer in the Tools Guide |
In this example, you click on the text button btnStartTimer to set the value of the integer field fldTimerValue to 0 and to start the timer tmrUser. This button fires the TimerTicked event on the timer, which is coded to get the current value and increment it one unit. The running value is displayed in fldTimerValue.
This code is in the actionPerformed event for the btnStartTimer button.
// Set the counter to 0 fldTimerValue.setValue(0); // Start the timer tmrUser.startTimer();
This code is in the timeIntervalExpired event of tmrUser Timer control.
// Timer has ticked, so increment the counter by 1 fldTimerValue.setValue(fldTimerValue.getValue() + 1); // Add a row to the trace list box to show that the timer has ticked subfrmTrace.lbEventList.addRow("tmrUser => TimerTicked");
The timer resumes after each timeIntervalExpired event until you stop it. The following code uses the stopTimer()
method to stop tmrUser.
This code is in the actionPerformed event of the btnStopTime button.
// Stop the timer tmrUser.stopTimer();