import java.awt.*; import java.util.*; public class Showtime extends Frame implements Runnable { Button quitBtn; Label timeLbl; Thread tthread; public Showtime() { super("Java Showtime"); setLayout(new FlowLayout()); quitBtn = new Button("Quit"); timeLbl = new Label((new Date()).toString()); add(quitBtn); add(timeLbl); pack(); show(); tthread = new Thread(this); tthread.run(); } public boolean action(Event evt, Object what) { if (evt.target == quitBtn) { tthread.stop(); System.exit(0); } return super.action(evt,what); } public void run() { while(true) { try { Thread.sleep(10000); } catch (Exception e) { } timeLbl.setText((new Date()).toString()); } } public static void main(String [] argv) { Showtime st = new Showtime(); } }