title: How To Reset a Timer in Java GUI and Display Message after Stop
body: <p>Hello Good day i want to create a "Reset Button" where my Timer will reset. I created a new button and named it as "reset" and i use the code "tm2.restart();" but its not working in my created New Button. This is my code:</p>
  
  <pre><code>import javax.swing.Timer;
  public class deploy extends JFrame {
  
   private int seconds;
   private SimpleDateFormat df;
   private boolean isRunning;
   private JLabel lblTimer1;
   private JButton btnStart1;
  
  public deploy() {
  
  lblTimer1 = new JLabel("New label");
  lblTimer1.setForeground(Color.WHITE);
  lblTimer1.setFont(new Font("Tahoma", Font.PLAIN, 20));
  lblTimer1.setBounds(100, 231, 94, 16);
  contentPane.add(lblTimer1);
  
   Timer tm2 = new Timer(1000, new ActionListener() {
  
             @Override
              public void actionPerformed(ActionEvent e) {
                  setTimer();
                  seconds++;
              }
          });
  
  btnStart1 = new JButton("Start");
  btnStart1.setBackground(Color.LIGHT_GRAY);
  btnStart1.setForeground(Color.BLUE);
  btnStart1.addActionListener(new ActionListener() {
       @Override
             public void actionPerformed(ActionEvent e) {
  
                  if(isRunning) {
                      tm2.stop();
                      btnStart1.setText("Start");
                  }else {
                      tm2.start();
                      btnStart1.setText("Stop");
                  }
  
                  isRunning = !isRunning;
              }
          });
  </code></pre>
  
  <p>My kind of timer is formatted as "SimpleDateFormat" (00:00:00) because i'm creating a "cybercafe management application" that the customer will walk in and records his/her time until he/she logged out and display a message the amount he/she will be payed off. please help. thanks</p>