Add the following code to Midlet.java to initialise LWUIT and create the first form:
package com.example; import javax.microedition.midlet.MIDlet; import com.sun.lwuit.Display; import com.sun.lwuit.Form; public class Midlet extends MIDlet { public void startApp() { Display.init(this); Form form = new Form("Hello World"); form.show(); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
Display.init is a static method that creates a device-specific implementation class instance behind the scenes, and sets some parameters based on, for example, the number of softkeys and whether or not the device has a touch screen. Forms in LWUIT are analogous to LCDUI forms and represent different screens in the MIDlet.