Hii, I have this program and i need help on printing out the total time, can anyone help me on this?
If there is a better way to do this let me know
Thnx
import javax.swing.*;
import javax.swing.Tim er;
import java.awt.event. *;
public class MyTimer{
public static void main (String [] args){
class TimeListener implements ActionListener{
public void actionPerformed (ActionEvent e) {
//...
}
}
ActionListener timeListen = new TimeListener();
Timer t = new Timer(1000, timeListen);
t.start();
JOptionPane.sho wMessageDialog( null, "Start timer");
//...
t.stop();
JOptionPane.sho wMessageDialog( null, "Stop timer");
System.out.prin tln(t);
}
}
If there is a better way to do this let me know
Thnx
import javax.swing.*;
import javax.swing.Tim er;
import java.awt.event. *;
public class MyTimer{
public static void main (String [] args){
class TimeListener implements ActionListener{
public void actionPerformed (ActionEvent e) {
//...
}
}
ActionListener timeListen = new TimeListener();
Timer t = new Timer(1000, timeListen);
t.start();
JOptionPane.sho wMessageDialog( null, "Start timer");
//...
t.stop();
JOptionPane.sho wMessageDialog( null, "Stop timer");
System.out.prin tln(t);
}
}
Comment