/** Fancied up HelloWorld. * © Lee Higbie & Arctic Region Supercomputing Center, 2006 * higbie at arsc dot edu www.arsc.edu * This program may be copied and modified provided this notice is * preserved and a reasonable attempt is made to notify Lee Higbie * and ARSC of the changes made. */ import java.awt.*; // all the windowing stuff like Buttons import java.awt.event.*; // for mouse click and window listeners public class HelloBill extends Frame implements ActionListener, WindowListener { // class variables available to all objects--instances of class static String title = "Hi Bill"; // static for use in main Button disposeBtn = new Button("Exit"); /** @param args the command line args, an array of Strings */ public static void main (String [] args) { // appl entry point if (args.length > 0) { System.out.println ("Hello "+ args[0] +" with " + args.length +" args."); } else { // end if there are really arguments System.out.println ("Hello Pirate (argless user)."); } // end else, no arguments on command line HelloBill cg = new HelloBill(title); // cr. HelloBill obj } // end method main public HelloBill (String t) { // for creating a HelloBill obj super (t); // call the Frame constructor disposeBtn.addActionListener(this);// tells: respond to mouse clicks add(disposeBtn); // adds dispose button to this setVisible(true); // allows you to see this addWindowListener(this); // for clicks on window buttons } // end of constructor // The rest of the class is the code for responding to external events public void actionPerformed(ActionEvent ae) { // required by ActionListener interface System.out.println("Dialog @ HelloBill 37 "+ae); // prints a line on java console so you can see action this.dispose(); // closes window } // end of actionPerformed method // rest of methods are required by the WindowListener interface public void windowClosing (WindowEvent we){ System.out.println ("Window closing at HelloBill 46"); System.exit(0); } // end of windowClsing method public void windowActivated (WindowEvent we){ } // all null public void windowClosed (WindowEvent we){ } // methods public void windowDeactivated (WindowEvent we){ } public void windowDeiconified (WindowEvent we){ } public void windowIconified (WindowEvent we){ } public void windowOpened (WindowEvent we){ } } // end HelloBill class