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)
  ...
4

3 回答 3

2

您可以检查以下代码:

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) {
    }
}
于 2012-11-16T04:51:52.020 回答
0

代码对我来说看起来不错。请检查是否getAboutText()返回一个字符串并且不返回 null。

如果这没有帮助,您可以使用 LWUIT-Sources 来调试您的代码。在 TextArea.shouldShowHint 处设置一个断点并找出它是空的。

于 2012-11-19T15:23:33.227 回答
0

查看

导入 com.sun.lwuit.TextArea;

于 2013-05-15T22:44:35.720 回答