Image resources

There are several types of images in LWUIT, most of which can be stored either individually in the Java archive (JAR™) or packaged as part of a resource bundle.

To load an image stored in the JAR file, use the following code:

Image image = Image.createImage("/images/duke.png");

The Image tag supports the following attributes:

name

The name of the resource (defaults to the name of the file name).

file

The file that would be used for the image (required).

Once loaded, the image is ready to be used as a background image of a component or even as an icon for a component that can contain an image.

Handling images in Resource Editor

The LWUIT Resource Editor supports the following image types:

  • RGB: Standard JPG/PNG formats. Indexed PNGs also work very well (and are highly recommended) with this image type.

  • SVG: SVG Tiny images are supported. LWUIT can optionally seamlessly generate PNG images for the SVG files when a device doesn't support SVG.

  • Multi-Image: One can add several images based on the DPI of the device (one of several predefined family ranges). Irrelevant images are skipped when loading the resource file .

    Multi-images are ideal for icons or small artifacts that are hard to scale properly. They are not meant to replace things such as 9-image borders and so forth since adapting them to every resolution or to device rotation isn't practical.

  • Timeline: A timeline is a set of images that can be moved rotated, scaled, and blended to provide interesting animation effects.Timelines allow rudimentary animation and enable GIF importing using the resource editor.