/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ File: GraphicsExampleFrame1.java Date: 12/20/2005 Author: mr. Hanley Purpose: Demonstrate simple drawing of shapes to the frame @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ import java.awt.*; import java.awt.image.*; //for BufferedImage import javax.swing.*; public class GraphicsExampleFrame1 extends JFrame { //A BufferedImage will store our image BufferedImage img= new BufferedImage(500,400,BufferedImage.TYPE_INT_ARGB); //this will be used to render stuff int x = 8, y = 38; public void update(Graphics g) { paint(img.getGraphics()); g.drawImage(img,0,0,null); } public void paint(Graphics g) { //Erase the window g.setColor(new Color(100,50,25)); g.fillRect(0,0,500,400); //Draw a ball g.setColor(Color.red); g.fillOval(x, y, 20, 50); x+=50; y+=40; //Pause try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } //Invoke repaint repaint(); } }