// HowToG.java provides a simple AWT GUI example import java.awt.*; import java.awt.event.*; class HowToG implements ActionListener { public static void main(String[] args) { int count = 3; if (args.length > 0) count = Integer.parseInt(args[0]); HowToG gui = new HowToG(count); } Frame frm; Label lab; Button btn; int n; public HowToG(int count) { n = count; frm = new Frame("Welcome to the HowToG program"); lab = new Label("Countdown at " + count, Label.CENTER); btn = new Button("Click here to continue"); btn.addActionListener(this); // no extra object used here frm.setLayout(new BorderLayout()); frm.add(lab, "Center"); frm.add(btn, "South"); frm.setBounds(200, 100, 400, 200); frm.setVisible(true); } public void actionPerformed(ActionEvent e) { if (--n > 0) { lab.setText("Countdown at " + n); } else { frm.dispose(); System.out.println("Countdown finished"); System.exit(0); } } }