import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Canvas extends JPanel {
// Remember in ivar so can redraw
private ImageIcon icon1, icon2; //*2 Remember images in ivar so can redraw
Canvas () {
icon1 = new ImageIcon ("redBall.gif"); //*1 Get the images
icon2 = new ImageIcon ("blueBall.gif"); //*1
}
// This is our draw callback
public void paintComponent (Graphics g) { //*3 Draw the images
super.paintComponent(g);
icon1.paintIcon (this, g, 100, 100); //*3
icon2.paintIcon (this, g, 200, 200); //*3
g.drawLine (50, 50, 100, 50); //*4 Draw the line from previous examples
}
}