Java Reference
In-Depth Information
Figure 11.2. An ImageIconProxy object forwards paint() requests to the current
ImageIcon object.
When the user clicks Load, your code will cause the ImageIconProxy object to change its
current image to be the Loading… image. The proxy will also begin loading the desired
image. When the desired image is completely loaded, the ImageIconProxy object will
change its current image to be the desired image.
To set up a proxy, you can create a subclass of ImageIcon , as Figure 11.3 shows. The code
for ImageIconProxy defines two static variables that contain the Absent and Loading…
static final ImageIcon ABSENT =
new ImageIcon("absent.jpg");
static final ImageIcon LOADING =
new ImageIcon("loading.jpg");
Search WWH ::

Custom Search