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

public class TimerTest3
{
   private static int count;

   public static void main(String[] args)
   {
      count = Integer.parseInt(args[0]);        // getting the countdown
      ActionListener listener = new ActionListener()  
      {
         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
         }
      };

      Timer t = new Timer(1000, listener);          // timer declaration
      t.start();                                    // starting the timer
      JOptionPane pane = new JOptionPane(null);
   }
}

