public class ShapesTest
1: // Fig. 5.27: ShapesTest.java
2: // Test application that displays class Shapes.
3: import javax.swing.JFrame;
4: import javax.swing.JOptionPane;
6: public class ShapesTest
7: {
8: public static void main( String args[] )
9: {
10: // obtain user's choice
11: String input = JOptionPane.showInputDialog(
12: "Enter 1 to draw rectangles\n" +
13: "Enter 2 to draw ovals" );
14:
15: int choice = Integer.parseInt( input ); // convert input to int
16:
17: // create the panel with the user's input
18: Shapes panel = new Shapes( choice );
19:
20: JFrame application = new JFrame(); // creates a new JFrame
22: application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
23: application.add( panel ); // add the panel to the frame
24: application.setSize( 300, 300 ); // set the desired size
25: application.setVisible( true ); // show the frame
26: } // end main
27: } // end class ShapesTest
30: /**************************************************************************
31: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
32: * Pearson Education, Inc. All Rights Reserved. *
33: * *
34: * DISCLAIMER: The authors and publisher of this book have used their *
35: * best efforts in preparing the book. These efforts include the *
36: * development, research, and testing of the theories and programs *
37: * to determine their effectiveness. The authors and publisher make *
38: * no warranty of any kind, expressed or implied, with regard to these *
39: * programs or to the documentation contained in these books. The authors *
40: * and publisher shall not be liable in any event for incidental or *
41: * consequential damages in connection with, or arising out of, the *
42: * furnishing, performance, or use of these programs. *
43: *************************************************************************/