/** * The driver for this lab 7. * * @param args * is an array of {@code Strings} which hold the names of shapes * to draw. */ public static void main(String[] args) { List shapesToDraw = new ArrayList(); String currentShapeName = ""; if (args.length <= 0) System.out .println("Please provide arguments as to what shape(s) (Square, Circle or Triangle) you would like to draw."); else { // fill the list for (int i = 0; i < args.length; i++) { // can't switch on Strings in Java < 1.7... Gah. currentShapeName = args[i]; if (currentShapeName.equalsIgnoreCase("Circle")) shapesToDraw.add(Shape.CIRCLE); else if (currentShapeName.equalsIgnoreCase("Square")) shapesToDraw.add(Shape.SQUARE); else if (currentShapeName.equalsIgnoreCase("Triangle")) shapesToDraw.add(Shape.TRIANGLE); else { // I don't know what shape this is. Explode. System.out .println("This program only draws Squares, Circles or Triangles. Sorry."); System.exit(0); } } JFrame mainFrame = new JFrame("Shape Artist"); int maxSize = 500; JPanel shapePanel = new ShapePanel(shapesToDraw, maxSize); shapePanel.setPreferredSize(new Dimension(maxSize, maxSize)); // add the JPanel to the pane mainFrame.getContentPane().add(shapePanel, BorderLayout.CENTER); // clean up mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.pack(); mainFrame.setResizable(false); mainFrame.setVisible(true); } }