import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Canvas extends JPanel { // Remember in ivar so can redraw ImageIcon icon1, icon2; Canvas () { icon1 = new ImageIcon ("redBall.gif"); icon2 = new ImageIcon ("blueBall.gif"); } // This is our draw callback public void paintComponent (Graphics g) { super.paintComponent(g); icon1.paintIcon (this, g, 100, 100); icon2.paintIcon (this, g, 200, 200); g.drawLine (50, 50, 100, 50); } }