How to include a user component to LWUIT 1.5 GUI Builder?
-
27-05-2021 - |
Question
I'd like to have any Form
managed through the StateMachine
generated from LWUIT's 1.5 GUI Builder but I have my component which extends Components
and also my own Layouts
. How to add them to gui builder as custom Component
?
Solution
You have two ways. The first override:
protected Component createComponentInstance(String componentType, Class cls)
Which allows you to replace all components of a given type (E.g. make your own subclass for all the forms).
The second option is to add them at runtime.
We used to allow used components using the pickMIDlet functionality but that's a bit problematic since a user class might not be compilable while editing a res file.
OTHER TIPS
You must create them in the GUI builder, you can't export your own Component
from code to the GUI Builder. Build them in the Gui Builder and if this component is a Container
you can create instance of this usign StateMachine.createContainer(resource, "nameContainer");
. To manage the Forms
through the StateMachine
, you can use StatMachine.showForm("nameForm");
to show a Form
and StateMachine.back()
to go back in the navigation.