Source Code : Tick Tock with a Static Inner Class

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Tick Tock with a Static Inner Class

  

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;
import javax.swing.Timer;

public class MainClass {
  public static void main(String[] args) {
    Timer t = new Timer(1000, new Ticker());
    t.start();
    JOptionPane.showMessageDialog(null, "Click OK to exit program");
    System.exit(0);
  }

  static class Ticker implements ActionListener {
    private boolean tick = true;

    public void actionPerformed(ActionEvent event) {
      if (tick) {
        System.out.println("Tick...");
      } else {
        System.out.println("Tock...");
      }
      tick = !tick;
    }
  }
}

   
  

Thank with us