Programming
J2ME Polish provides many APIs to rapdily develop mobile apps.
JavaDoc
You can find general documentation within the JavaDocs of J2ME Polish:
JavaDoc.
UI Programming
You can use normal MIDP programming when using J2ME Polish, as the J2ME Polish
UI is compatible with the MIDP 2.0 standard. On MIDP
devices you can also mix MIDP UI and J2ME Polish UI classes by using classes such as
de.enough.polish.midp.ui.TextBox.
Please also check out the UI Basics documentation as well as the
Visual Guide.
Use #style preprocessing directives for binding UI components to CSS styles
defined in resources/polish.css:
package de.enough.polish.sample.browser;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import de.enough.polish.browser.html.HtmlBrowser;
public class BrowserMidlet
extends MIDlet
implements CommandListener
{
private Command cmdBack = new Command("Back", Command.BACK, 9);
private Command cmdExit = new Command("Exit", Command.EXIT, 10 );
private Form browserScreen;
private HtmlBrowser htmlBrowser;
protected void startApp() throws MIDletStateChangeException{
Display display = Display.getDisplay( this );
if (this.browserScreen == null) {
//#style browserScreen
Form form = new Form("HTML Browser");
//#style browser
this.htmlBrowser = new HtmlBrowser();
// you can add a gzip resource handler for reading gzipped resources:
//this.htmlBrowser.addProtocolHandler( new GZipResourceProtocolHandler() );
new ChartTagHandler( this.htmlBrowser.getTagHandler("div")).register(this.htmlBrowser);
form.append(this.htmlBrowser);
this.htmlBrowser.go( "resource://index.html");
this.htmlBrowser.setBackCommand( this.cmdBack );
form.addCommand( this.cmdExit );
form.setCommandListener( this );
this.browserScreen = form;
}
display.setCurrent( this.browserScreen );
}
protected void pauseApp(){
// ignore
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException{
// just exit
}
public void commandAction(Command cmd, Displayable disp) {
//#debug
System.out.println("BrowserMidlet.commandAction for cmd=" + cmd.getLabel() );
if (cmd == this.cmdBack) {
this.htmlBrowser.goBack();
} else if (cmd == this.cmdExit) {
//destroyApp( true );
notifyDestroyed();
}
}
}
Note that J2ME Polish includes many sample applications which you should look at.