J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software


J2ME Polish contains several often needed J2ME utilty classes:


  • XML: We have a minimum overhead & fast XML implementation for both SAX as well as DOM tree parsing.
  • JSON: With our optimized JSON parsing and construction you are ready any modern REST style webservice.
  • Atom News Feeds: Use, persist and parse Atom feeds easily with our Atom support
  • Bluetooth: Our Bluetooth classes ease the discovery of other Bluetooth devices and allow you to stream data over L2CAP connections.
  • Geometry 2D: Provides advanced 2D rendering mechanisms.
  • File Connection: Allows you to easily browse file directories.
  • Location: The location helper classes ease the retrieval and update of locations.
  • Math: The math package contains fixed point implementations for CLDC 1.0 devices and a BigInteger implementation for all.
  • Calendar: Our calendar classes contain both UI and model classes to manage calendars with recurring or one time events.
  • Audio: Our multimedia audio supplements ease the playback of audio.
  • Video: Allows you to capture and playback video.
  • PIM: Easily access contacts with the J2ME Polish PIM API.
  • Snapshot: Use the SnapshotUtil for capturing photo snapshots.
  • Base64 Encoding: Encode and decode base64 messages.
  • Sensor Access: Allows you to access accelator information easily.
  • GZip: Allows you to extract and compress GZip files.
  • General Utilities: J2ME Polish provides a whole bunch of utility classes like ArrayList, IntList, IntStack, HashMap, OAHashMap, TimePoint, TimePeriod and many more.

Specific Utilties

Using the BitMapFont Class

You can use the class de.enough.polish.util.BitMapFont for using bitmap fonts directly in your application. This is often useful in games and other application, when you want to show messages to the user which should not appear in the standard font-faces.

The involved concepts are quite easy:

  1. Create a bitmap font using the ${polish.home}/font-editor executable.
  2. Create a BitMapFont in your application.
  3. Use the BitMapFontViewer to display a message.

The following code illustrates the second and third step:

import de.enough.polish.util.*;

public class MyCanvas extends Canvas {

	private BitMapFont bitMapFont;
	privte BitMapFontViewer messageViewer;

	public MyCanvas() {
		this.bitMapFont = BitMapFont.getInstance("/coolfont.bmf");
		this.messageViewer = this.bitMapFont.getViewer("Hello World!");
		int availableWidth = getWidth() - 20;
		int padding = 2;
		int textOrientation = Graphics.LEFT;
		this.messageViewer.layout( availableWidth, availableWidth, padding, orientation );

	public void paint( Graphics g ) {
		int x = 10;
		int y = 20;
		this.messageViewer.paint( x, y, g );

Since the BitMapFont.getViewer(String)-method is the most expensive one, you should try to call it only when it's necessary, e.g. when a new message is generated.


J2ME Polish includes an ArrayList class, which is compatible to the J2SE class. Find more information at the JavaDoc documentation.

Some more specialized classes include the IdentityArrayList, IntList, LongList and BooleanList.


The TextUtil class contains several helper methods for text manipulation, e.g. a wrapping-algorithm and a split-tool. Have a look at the JavaDoc documentation.


Please refer to the JavaDoc documentation of these classes for further information.

back to top