previous |
start |
next
Deferred Image Loading
- Normally, programmer uses image for label:
JLabel label = new JLabel(new
ImageIcon(imageName));
- Use proxy instead:
JLabel label = new JLabel(new
ImageProxy(imageName));
- paintIcon loads
image if not previously loaded
public void
paintIcon(Component c, Graphics g, int x, int y)
{
if (image ==
null) image = new ImageIcon(name);
image.paintIcon(c, g, x, y);
}
previous |
start |
next