How to make it possible to add a LWUIT Form inside a LWUIT Form?

435 views Asked by At

I tried to add a LWUIT Form into another LWUIT Form but I received an internal error in runtime :

Installing suite from: http://127.0.0.1:1975/SmartPhoneBanking.jad
java.lang.IllegalArgumentException: A form cannot be added to a container
 - com.sun.lwuit.Container.insertComponentAt(), bci=50
 - com.sun.lwuit.Container.addComponent(), bci=19
 - com.sun.lwuit.Form.addComponent(), bci=5
 - view.test.<init>(), bci=63
 - view.MenuPrincipalForm.actionPerformed(), bci=178
 - com.sun.lwuit.util.EventDispatcher.fireActionSync(), bci=19
 - com.sun.lwuit.util.EventDispatcher.fireActionEvent(), bci=89
 - com.sun.lwuit.Button.fireActionEvent(), bci=70
 - com.sun.lwuit.Button.released(), bci=17
 - com.sun.lwuit.Button.pointerReleased(), bci=1
 - com.sun.lwuit.Form.pointerReleased(), bci=93
 - com.sun.lwuit.Component.pointerReleased(), bci=7
 - com.sun.lwuit.Display.handleEvent(), bci=125
 - com.sun.lwuit.Display.edtLoopImpl(), bci=115
 - com.sun.lwuit.Display.mainEDTLoop(), bci=198
 - com.sun.lwuit.RunnableWrapper.run(), bci=242
 - java.lang.Thread.run(), bci=11
Process exited with exit code 0

Although a LWUIT Form is a LWUIT Component ! So the addComponent should work with a LWUIT Form !

So how to make it possible ?

codes :

public class test extends Form
{
   private Button b = new Button("xxx");
   public test(String t)
   {
      super(t);
      addComponent(b);
   }
}

In another Form :

...
private Form xxx = new test("xxx");
...
addComponent(xxx);
...
1

There are 1 answers

4
Shai Almog On

You are adding a form to a container, says it right in the exception when you add xxx to wherever it is you are adding it to.

Use xxx.show() do not add it to anything.