import javax.swing.Timer;
import javax.swing.JOptionPane;
import java.awt.event.*;

public class TimerTest1
{
   public static void main(String[] args)
   {
      int count = Integer.parseInt(args[0]);         // getting the countdown
      CountDown countDown = new CountDown(count);    // timer events listener
      Timer t = new Timer(1000, countDown);          // timer declaration
      t.start();                                     // starting the timer
      JOptionPane pane = new JOptionPane(null);
   }
}

// this class is performed as a listener for the timer events
class CountDown implements ActionListener
{
   private int count;                                // countdown value

   public CountDown(int value)                       // setting the instance var
   {
      count = value;
   }

   public void actionPerformed(ActionEvent e)        // will be called at each
   {                                                 // timer event
      System.out.println(count);
      if (count > 0)
         count--;
      else
         System.exit(0);                             // terminate the program
   }
}
