1

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)
  ...
YETI
  • 928
  • 3
  • 12
  • 24

3 Answers3

2

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) {
    }
}
String
  • 3,660
  • 10
  • 43
  • 66
  • Sorry, I run it in nokia s40 sdk 2.0. When I run most of codes that include TextArea, exception ocurred; – YETI Nov 16 '12 at 13:10
  • Even me to tested on Nokia SDK 2.0,I'm getting the result successfully – String Nov 17 '12 at 04:01
  • I said its not all the Sample for TextArea. And the exception was real one I recoded .Please import "\Nokia_SDK_2_0_Java\plugins\lwuit\examples\LWUITDemo" and run it.I just want to know how to prevent the exception which i listed. – YETI Nov 18 '12 at 12:14
0

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.

Meier
  • 3,858
  • 1
  • 17
  • 46
0

Check

import com.sun.lwuit.TextArea;

C3s4R
  • 1