YETI
YETI

Reputation: 938

LWUIT TextArea NullPointerException

I run LWUITDemo, Some UI can not be shown successful.All of them are TextArea contained by Form.If I change TextArea to Label, it work well.

Sorry, I run it in nokia s40 sdk 2.0. When I run most of codes that include TextArea, exception ocurred;

The Code Like That(From LWUITDemo):

Form aboutForm = new Form("About");
aboutForm.setScrollable(true);
aboutForm.setLayout(new BorderLayout());
TextArea aboutText = new TextArea(getAboutText(), 5, 10);
aboutText.setEditable(false);
aboutForm.addComponent(BorderLayout.CENTER, aboutText);
aboutForm.show();

When I run it, it faild:

Form: showModal
java.lang.NullPointerException
  at com.sun.lwuit.TextArea.shouldShowHint(+21)
  at com.sun.lwuit.TextArea.calcPreferredSize(+4)
  at com.sun.lwuit.Component.preferredSize(+63)
  ...

Upvotes: 1

Views: 241

Answers (3)

C3s4R
C3s4R

Reputation: 1

Check

import com.sun.lwuit.TextArea;

Upvotes: 0

Meier
Meier

Reputation: 3880

The code looks good to me. Please check that getAboutText() returns a String and does not return null.

If this does not help, you can use the LWUIT-Sources to debug your code. Set a breakpoint at TextArea.shouldShowHint and find out what it is that is null.

Upvotes: 0

String
String

Reputation: 3728

You Could Check below Code:

import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.layouts.BorderLayout;
import javax.microedition.midlet.*;

public class TextMidlet extends MIDlet {

    private Form aboutForm;

    public TextMidlet() {
        Display.init(this);

        aboutForm = new Form();
        aboutForm.setScrollable(true);
        aboutForm.setLayout(new BorderLayout());
    }

    public void startApp() {

        TextArea aboutText = new TextArea("hiiiiiiiiiiiiii", 5, 10);
        aboutText.setEditable(false);
        aboutForm.addComponent(BorderLayout.CENTER, aboutText);
        aboutForm.show();
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}

Upvotes: 2

Related Questions