提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
内部接口示例,用于实现接口
import java.awt.event.*; import javax.swing.*;//N o w J a v a . c o m - 时代Java 提 供 public class TickTockInner { private static String tickMessage = "Tick..."; private static String tockMessage = "Tock..."; public static void main(String[] args) { TickTockInner t = new TickTockInner(); t.go(); } private void go() { Timer t = new Timer(1000, new Ticker()); t.start(); /** 来 自 时代Java - nowjava.com**/ 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)