March 2002
Intermediate to advanced
496 pages
8h 51m
English
| SOLUTION 11.1 | The image-display methods of ImageIconProxy forward their calls to the current image:
public int getIconHeight()
{
return current.getIconHeight();
}
public int getIconWidth()
{
return current.getIconWidth();
}
public synchronized void paintIcon(
Component c, Graphics g, int x, int y)
{
current.paintIcon(c, g, x, y);
}
|
| SOLUTION 11.2 | The load() method sets the image to Loading…, whereas the run() method, executing in a separate thread, loads the desired image:
public void load(JFrame callbackFrame)
{
this.callbackFrame = callbackFrame;
setImage(LOADING.getImage());
callbackFrame.repaint();
new Thread(this).start();
}
public void run()
{
setImage(new ImageIcon(filename).getImage());
callbackFrame.pack();
}
|
Read now
Unlock full access