import java.awt.*; import javax.swing.*; /** A panel in which SmileyFace objects are drawn. */ public class DrawFacesPanel extends JPanel { // Variable declarations. private final int WIDTH = 500; private final int HEIGHT = 500; private SmileyFace smileyFace; // The constructor below will be called when an instance of this class is created. public DrawFacesPanel() { setPreferredSize(new Dimension(WIDTH,HEIGHT)); smileyFace = new SmileyFace( 100, 100, 30, 1 ); // Create a SmileyFace object. } // The paintComponent method gets automatically called by the Java painting system. public void paintComponent(Graphics g) { super.paintComponent(g); // Draw the SmileyFace object (referenced BY smileyFace) 20 times at different horizontal positions in the application window. int i = 0; while (i <= 380) { smileyFace.draw(g, i + 50, 0); i += 20; } // Draw the SmileyFace object (referenced BY smileyFace) 20 times at different vertical positions in the application window. i = 0; while (i <= 380) { smileyFace.draw(g, 0, i + 50); i += 20; } i = 0; // Draw the SmileyFace object (referenced BY smileyFace) 20 times at different diagonal positions in the application window. while (i <= 380) { smileyFace.draw(g, i + 50, i + 50); i += 20; } } }