0

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);
...
Mun0n
  • 4,438
  • 4
  • 28
  • 46

1 Answers1

2

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.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • But I want to make a `transition` about the Button contained in it. So that's why I want to add the Form. So if calling `show()` then the new Form will occupy all of the area of the already shown form ! But I want just an area to be occupied ! –  Nov 03 '11 at 05:39
  • addComponent will not form a transition, only replace. Regardless of that, what is the behavior you expect with adding a form into a place of a button? Do you want the entire title and everything to appear where the button is? – Shai Almog Nov 06 '11 at 06:35
  • I want the Button to have a Transition appearance when adding it into a Form. –  Nov 09 '11 at 07:48
  • 1
    You are adding the form to the container not the button to the form which is wrong regardless of what you are trying to do. To do a simple animation just use replace() which accepts a transition. In LWUIT 1.5 you can also animate the layout so a button will "fly in" see the LWUITDemo 1.5's animations demo for samples of that. – Shai Almog Nov 10 '11 at 07:07