在我点击 but子时,我想显示点击时间。 如果我们点击纽顿,请送我显示时间的代码。
I have a TFrame (fraDisplay) with a TTimer (timAnimateDataChange). The timer is used to control a small animation. In the form containing the frame I want to have a method that does something like ...
在我点击 but子时,我想显示点击时间。 如果我们点击纽顿,请送我显示时间的代码。
尝试这项法典
import java.util.Timer;
import java.util.TimerTask;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
public class stopwatch extends MainScreen
{
private RichTextField _chronometer;
Timer timer;
private int second = 0, minute = 0, hour = 0;
private boolean _sec = false, _min = false, _hou = false;
ButtonField record,stop;
public stopwatch()
{
record=new ButtonField("Start");
stop=new ButtonField("Stop");
_chronometer = new RichTextField("0" + hour + ":0" + minute + ":0" + second, RichTextField.TEXT_ALIGN_HCENTER | Field.NON_FOCUSABLE);
add(_chronometer);
HorizontalFieldManager hfm=new HorizontalFieldManager(FIELD_HCENTER);
record.setMargin(net.rim.device.api.system.Display.getHeight()/2,0,0,0);
stop.setMargin(net.rim.device.api.system.Display.getHeight()/2,0,0,20);
hfm.add(record);
hfm.add(stop);
add(hfm);
FieldChangeListener listener = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if(field==record){
try
{
try {
timer = new Timer();
resetChronometer();
timer.scheduleAtFixedRate(new Chronometer(), 1000, 1000);
} catch (Exception e) {
e.printStackTrace();
}
}
catch (Exception e)
{
Dialog.alert(e.toString());
}
}
if(field==stop){
try
{
timer.cancel();
}
catch (Exception e)
{
Dialog.alert(e.toString());
}
}
}
};
record.setChangeListener(listener);
stop.setChangeListener(listener);
}
private class Chronometer extends TimerTask {
public void run() {
try {
second++;
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
if (_min == true) {
_min = false;
minute = minute + 1;
second = 0;
}
if (_hou == true) {
_hou = false;
hour = hour + 1;
minute = 0;
}
if (second == 59) {
_min = true;
if (minute == 59) {
_hou = true;
}
}
if (second <= 9 && minute <= 9 && hour <= 9) {
_chronometer.setText("0" + hour + ":0" + minute + ":0" + second);
}
if (second > 9 && minute <= 9 && hour <= 9) {
_chronometer.setText("0" + hour + ":0" + minute + ":" + second);
}
if (second <= 9 && minute > 9 && hour <= 9) {
_chronometer.setText("0" + hour + ":" + minute + ":0" + second);
}
if (second <= 9 && minute <= 9 && hour > 9) {
_chronometer.setText("" + hour + ":0" + minute + ":0" + second);
}
if (second > 9 && minute > 9 && hour > 9) {
_chronometer.setText(hour + ":" + minute + ":" + second);
}
if (second > 9 && minute > 9 && hour <= 9) {
_chronometer.setText("0" + hour + ":" + minute + ":" + second);
}
if (second > 9 && minute <= 9 && hour > 9) {
_chronometer.setText("" + hour + ":0" + minute + ":" + second);
}
if (second <= 9 && minute > 9 && hour > 9) {
_chronometer.setText("0" + hour + ":" + minute + ":" + second);
}
// rt.setText(hour+":"+minute+":"+second);
}
});
// timer.cancel();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void resetChronometer() {
_chronometer.setText("00:00:00");
second = 0;
minute = 0;
hour = 0;
}
}
I have a TFrame (fraDisplay) with a TTimer (timAnimateDataChange). The timer is used to control a small animation. In the form containing the frame I want to have a method that does something like ...
How can I know how long the current page has been loaded using Jquery or Javascript? What function?
I have a web application and I m attempting to put an ajax timer control in it to give me a post back every 10-20 seconds. (possibly longer depending on performance). I have a lot of dynamically ...
I m asking a question very similar to this one—dare I say identical? An example is currently in the bottom navigation on this page. I m looking to display the name and link of the next and previous ...
This is not your typical 1120. I know better than to have buttons/MCs without instance names on the timeline. Nope, this problem resides in a I timer I built from script I found online. The undefined ...
i have a timer that calls its even handler method every 30 seconds. but i want to initialy call this method. the signature of the event handler method is void TimerElapsed_GenerateRunTimes(object ...
I wrote a Timer class in order to use it within a windows service that is polling another system. I did this because I had two issues that the System.Timers.Timer is not addressing. The Elapsed ...
I want a program to stop executing for a certain amount of time. And i want this to happen in regular intervals. For example, i want a program to run for 5 minutes and then it should stop for 2 ...