* @return The resulting <code>Image</code> object.
* @throws java.io.IOException
* If an error occurred while reading from the stream.
*/
private synchronized Image loadImage(InputStream stream) throws IOException {
Toolkit toolkit = Toolkit.getDefaultToolkit();
byte data[] = FileCopyUtils.copyToByteArray(stream);
Image image = toolkit.createImage(data);
imageLoaded = false;
imageError = false;
// fully loads the image into memory
toolkit.prepareImage(image, -1, -1, this);
while (!imageLoaded && !imageError) {
try {
wait();
}
catch (InterruptedException ex) {