尝试在 lwuit 表单上显示对话框警报时遇到一个奇怪的异常。
java.lang.NullPointerException
at com.sun.lwuit.TextArea.shouldShowHint(+21)
at com.sun.lwuit.TextArea.calcPreferredSize(+4)
at com.sun.lwuit.Component.preferredSize(+63)
at com.sun.lwuit.Component.getPreferredSize(+4)
at com.sun.lwuit.Component.getPreferredW(+4)
at com.sun.lwuit.layouts.FlowLayout.layoutContainer(+139)
at com.sun.lwuit.Container.doLayout(+8)
at com.sun.lwuit.Container.layoutContainer(+16)
at com.sun.lwuit.Container.doLayout(+40)
at com.sun.lwuit.Container.layoutContainer(+16)
at com.sun.lwuit.Container.doLayout(+40)
at com.sun.lwuit.Container.layoutContainer(+16)
at com.sun.lwuit.Container.revalidate(+18)
at com.sun.lwuit.Dialog.showPacked(+107)
at com.sun.lwuit.Dialog.showImpl(+76)
at com.sun.lwuit.Dialog.show(+5)
at com.sun.lwuit.Dialog.showDialog(+9)
at com.test.MainView.ShowAlert(+82)
at com.test.MainView.ShowGameOverAlert(+45)
at com.test.MainView.<init>(+209)
at com.test.Main.startApp(+29)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
我使用了以下两段代码:
Dialog validDialog = new Dialog("Alert");
validDialog.setScrollable(false);
validDialog.setIsScrollVisible(false);
validDialog.setTimeout(5000); // set timeout milliseconds
TextArea textArea = new TextArea("...."); //pass the alert text here
textArea.setFocusable(false);
textArea.setIsScrollVisible(false);
validDialog.addComponent(textArea);
validDialog.show(0, 100, 10, 10, true);
Ref.:使用 LWUIT 弹出警报
和
Dialog d = new Dialog(title);
TextArea l = new TextArea(1, 20);
l.setText(message);
l.setHint("no hint");
l.setSingleLineTextArea(false);
l.setEditable(false);
l.setGrowByContent(true);
d.addComponent(l);
d.setDialogType(Dialog.TYPE_INFO);
d.setDialogPosition(BorderLayout.CENTER);
d.showDialog();
如果有人可以向我指出 lwuit 的源代码,那将是最有帮助的。
我在谷歌代码上发现了一个名为 lwuitfixes 的项目,它在 TextArea.java 和官方网站https://lwuit-incubator.dev.java.net/中没有任何功能“shouldShowHint”,从不打开!!!!!!!!!