How to create a timertask , a simple reminder application
451 viewsHere's a demo I wrote to show an example of the usage of a timertask. This demo will show a "reminder" dialog after x seconds.
JAVA:
-
Timer timer;
-
JButton ok;
-
public TimerTaskDemoV2(int seconds) {
-
timer.schedule(new RemindTask(), seconds*1000);
-
}
-
public TimerTaskDemoV2(){
-
getContentPane().setLayout(null);
-
info.setEditable(false);
-
info.setBounds(0,0,200,100);
-
ok.addActionListener(this);
-
ok.setBounds(0,100,200,30);
-
add(info);
-
add(ok);
-
setTitle("Reminder");
-
setDefaultCloseOperation(0);
-
setSize(207,155);
-
setResizable(false);
-
setLocationRelativeTo(null);
-
setVisible(true);
-
}
-
public void run() {
-
TimerTaskDemoV2 tmp = new TimerTaskDemoV2();
-
timer.cancel();
-
}
-
}
-
if(e.getSource() == ok){
-
}
-
}
-
int wait = 5;
-
new TimerTaskDemoV2(wait);
-
}
-
}














April 14th, 2008 at 5:40 pm
Save me man i got invalid or corrupt jarfile :'(
April 14th, 2008 at 6:54 pm
Uhm there no Jar file available. lol