Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
For this reason, the Java class library was designed to support asynchronous loading of media, such as images. Asynchronous loading means that loading occurs out of step with the rest of the application -- in another thread -- in the background. In fact, what might be thought of as one operation, the loading of an image from across the network, actually occurs in two distinct stages, which often occur asynchronously. These stages are: image definition and the actual downloading of the image.
In this column, I will take a close look at the mechanics of image loading from the perspective of a Java applet or similar network-based Java application. I will also provide a step-by-step demonstration of how to load and draw images within an applet.
But first, let's take a look at the principle players.
An instance of the Image class represents image data. The image data does not need to reside locally; it may exist on another computer. In fact, it
may not exist at all. An instance of the Image class is more like a reference to image data, than a container for image data.
Consider an image on a computer across a network. The creation of an instance of the Image class on a local computer does not cause the image data to be pulled across the network. This is true because instantiation
of the Image class does not cause reconstruction of the image data. The Image class doesn't even provide methods for initiating image reconstruction. (This class does, however, provide access to an ImageProducer object that does provide such methods -- I will talk about image producers next month.)
Although the Image class doesn't store image data, it does provide methods for obtaining information about an image. The following methods return
such information:
int getHeight(ImageObserver obs);
int getWidth(ImageObserver obs);
Object getProperty(String nm, ImageObserver obs);
The height and width values returned from the first two methods indicate the size of the image, in pixels. Properties, on
the other hand, are image-format-specific pieces of information about an image, and are retrieved by name. The only property
mentioned specifically in the Image class API is the comment property. It should contain a description of the image, or something similar. These methods return invalid values (the getHeight() and getWidth() methods both return -1 and the getProperty() method returns null) if the desired information is currently unavailable.
Image API http://www.javasoft.com/products/JDK/CurrentRelease/api/java.awt.Image.htmlGraphics API http://www.javasoft.com/products/JDK/CurrentRelease/api/java.awt.Graphics.htmlFree Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq