package start9_3_VirtualProxy; import javax.swing.Icon; import javax.swing.JComponent; import java.awt.Graphics; // Generic graphics component that contains an // icon that it uses for its visual display public class ImageComponent extends JComponent { private Icon icon; // the embedded icon // ctor public ImageComponent(Icon icon) { this.icon = icon; } @Override // Called by the Swing framework whenever this // ImageComponent needs to paint itself onto the canvas // @param graphics the Graphics "canvas" public void paintComponent(Graphics graphics) { super.paintComponent(graphics); // now tell the embedded icon to paint itself icon.paintIcon(this, graphics, 0, 0); } }