-1

I am getting a strange exception when trying to show Dialog alert on lwuit form.

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)

I used following two pieces of code:

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.: Alert pop up with LWUIT

and

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();

If someone could point me to source code of lwuit, it would be most helpful.
I found one project named lwuitfixes on google code that does not have any function 'shouldShowHint' inside TextArea.java and official site https://lwuit-incubator.dev.java.net/ never opens!!!!!!!

Community
  • 1
  • 1
vivek.m
  • 3,213
  • 5
  • 33
  • 48
  • The LWUIT incubator isn't the official site. Oracle shifted the sites to remove the word dev. its lwuit.java.net. – Shai Almog Mar 24 '13 at 19:42
  • @ShaiAlmog [lwuit.java.net](lwuit.java.net) still shows the link the above mentioned link under heading "How to Contribute?". Please share the link to download the source of LWUIT if it's available with you. – vivek.m Mar 25 '13 at 08:38
  • There used to be an SVN link in the LWUIT project page but the Oracle guys seem to have broken that project completely. Accessing the source code doesn't seem to work anymore. Typical. The only source is Codename One now. – Shai Almog Mar 25 '13 at 12:25
  • Yes, that's quite frustrating to hear.. I was trying LWUIT for a short weekend project that's over now, luckily! Thanks! – vivek.m Mar 25 '13 at 13:08

1 Answers1

0
l.setTextEditorEnabled(false);

stops the exception. (got hint by browsing the .class file of jar I am using)

Probably never seen a worse API than this.

To remove the white background of TextArea, I had to override its onPaint and fill the graphics with different color.

vivek.m
  • 3,213
  • 5
  • 33
  • 48