Oracle® Java Micro Edition Software Development Kit Developer's Guide Release 3.0.5 for Windows E24265-04 |
|
Previous |
Next |
JSR 258 (http://jcp.org/en/jsr/detail?id=258
) defines a standardized Java ME API for querying and manipulating themes and skins on a device. It also defines a file format for describing theme and skin data.
As specified in the JSR, you can define the theme (the appearance) in an XML file with local references to resource files (images, sounds and more) or it can be a JAR file that contains the XML file, its resources, and a properly defined manifest file.
You can use named colors or color values expressed in ARGB format.
Named colors must be recognized color keywords as found in the SVG 1.1 specification. See: http://www.w3.org/TR/SVG/types.html#ColorKeywords
Color values must be a numeric constant in the form #AARRGGBB, where the components RR, GG and BB are 8-bit values expressed as hexadecimal constants. AA is the opacity level, FF being fully opaque, and 00 fully transparent. For example, the ARGB value for white is #FFFFFFFF. See JSR 258 for a full explanation.
This MIDlet is a color converter that can be viewed using one of three appearances. The converter accepts a hexadecimal, decimal, or octal color specification and converts it to RGB format.
Follow these steps to run the demo:
Select a theme from the radio button list and press the Demo soft key.
Choose a system and enter a value in that format in the Enter Color field. The Alpha value is optional.
From the soft menu, choose option2, Process. The color converter displays the RGB value.
Appearances are associated with the device, in this case, the emulator. To see the XML files for this sample, go to the working directory for the current emulator. For example, see:
C:\Documents and Settings\
user\javame-sdk\3.0.5\work\
device-#\appdb\customization
The demo allows you to override these sample themes.
Make a copy of a theme file and store it in a different directory.
The sample expects the file names theme_green.xml
and theme_red.xml
. When a theme is revised it is overwritten in the emulator's working directory, so your edited copy must reside elsewhere.
Experiment with changing color values, fonts, or other settings, and save your changes. As mentioned earlier, color values must specified in ARGB format, or you can use an SVG 1.1 color keyword.
Run the demo, and in the emulator, choose Device > Customization. The external events generator opens with the Customization tab selected.
In the Appearances area, select the theme you have edited and press the Deinstall button. This does not delete the theme, it merely unloads it from this session.
Press the Install button and browse to select your edited theme. Installing overwrites the theme in the emulator's working directory.
Close the emulator.
Run the Customization project, and choose the revised theme. Verify that your changes are visible.
To restore the original themes, run the project and in the emulator, choose Device > Customization. Press Reset. This overwrites the current themes with the project's original themes.