import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.*;

public class Temp extends JFrame implements ActionListener{
   JButton button1;
   JLabel label;
   boolean isRunning = false;
   long myTime;

   public static void main(String args[]){
       new Temp();



   }

   /** Creates a new instance of Temp */
   public Temp() {
       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       this.getContentPane().setLayout(new GridLayout(2,1));

       label = new JLabel("0",SwingConstants.CENTER);
       this.getContentPane().add(label);

       button1 = new JButton("START");
       this.getContentPane().add(button1);
       button1.addActionListener(this);


       pack();
       setVisible(true);

   }

   public void actionPerformed(ActionEvent e){

       if (isRunning){
           button1.setText("START");
           isRunning = false;
           myTime = System.currentTimeMillis() - myTime;
           label.setText(myTime+"");
       }else{
           button1.setText("STOP");
           isRunning = true;
           myTime = System.currentTimeMillis();
       }
   }

}