import javax.swing.*; import java.awt.*; // the gameworld is a component, so it can be added to a GUI program class Canvas extends JComponent { @Override // overriding this method changes how it is shown public void paintComponent(Graphics g) { // just draw a black line on the window g.setColor(Color.green); g.fillOval(200, 200, 100, 100); } } public class SimpleGraphics { public static void main(String args[]) { // create and set up the window. JFrame frame = new JFrame("Graphics Example!"); // make the program close when the window closes frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // add the GameWorld component frame.add(new Canvas()); // display the window. frame.setSize(500, 500); frame.setVisible(true); } }