javamidlet

Is Display.getDisplay(this) supposed to display something?


I am learing to display in Mobile Java application. I came across this example to start with, but it doesn't display anything. I am trying to understand what Display.getDisplay(this) is doing in this code?

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;


public class Midlet extends MIDlet {

    private Display display = null;
    public void startApp() {
        if(display==null)
            display = Display.getDisplay(this);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}

Solution

  • You need to set some displayable to current display like

      Form form = new Form("Hello World");
      String msg = "Hello World!!!!!!!";
      form.append(msg);
      display = Display.getDisplay(this);
      display.setCurrent(form);