0

I'm trying to play with LWUIT and siMple app like "hello world"..
But first line in StartApp() - Display.init(this) - causes app to close throwing uncaught exception.. I'm totally confused..

import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Dialog;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class Main extends MIDlet {

    private int selectedIndex;
    private Form f;

    public Main() {}

public void startApp()  {
    System.out.println("before");
    try {
        System.out.println("during");
        Display.init(this);
    } catch(Exception h) {
        System.out.println("after");
        h.printStackTrace();
    }
}
  protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    // TODO Auto-generated method stub
    }
  protected void pauseApp() {
    // TODO Auto-generated method stub
    }

Please help.

DT7
  • 1,615
  • 14
  • 26
Dims
  • 163
  • 1
  • 12

2 Answers2

0

Take a look on your imports. I think that the problem is there. I will remove the javax.microedition.lcdui.*;

Here in this web, you can see, how the Nokia UI Demo starts.

Nokia UI DEMO MIDlet

Another solution that I find looking on my code. Put the Display.init(this)in the Midlet constructor instead in the startApp method.

Mun0n
  • 4,438
  • 4
  • 28
  • 46
0

Before any Form is shown the Developer must invoke Display.init(Object m) in order to register the current MIDlet.

Satyajit Gami
  • 51
  • 1
  • 1