// BasicGraphics.java // A simple shell for drawing graphics as described in our textbook. // Note that this is an *application* whereas the book uses *applets*. // This should have little impact on you, however. import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; public class BasicGraphics extends JComponent { public static void main(String[] args) { JComponent myGraphics = new BasicGraphics(); // Your class name goes here! launch(myGraphics, 500, 300); // Set the initial dimensions here! } public void paint(Graphics page) { int width = getWidth(); int height = getHeight(); // paint a blue rectangle as large as the window page.setColor(Color.blue); page.fillRect(0,0,width,height); // paint a yellow oval inscribed in the blue rectangle page.setColor(Color.yellow); page.fillOval(0,0,width,height); } ////////////////////////////////////////////////////////////////////////////// ///////////////// END OF YOUR CODE ///////////////////// ///////////////// (you may ignore all the code below!!! ///////////////////// ////////////////////////////////////////////////////////////////////////////// public static void launch(JComponent jc, int width, int height) { JFrame frame = new JFrame(jc.getClass().getName()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel cp = new JPanel(); cp.setLayout(new BorderLayout()); cp.add(jc); frame.setContentPane(cp); frame.setSize(new Dimension(width,height)); frame.setVisible(true); } }