5

I have built a LWUIT UI class which contains the Midlet. I am basically using a theme from this midlet. But I need to jump to another LCDUI form which contains some LCDUI controls and I need to set display that LCDUI form. So is it possible to jump from LWUIT form to LCDUI form and set display the LCDUI form ? If possible how ?

Abdullah Md. Zubair
  • 3,317
  • 2
  • 28
  • 38

2 Answers2

5

I used following code to show the both LWUIT Form and LCDUI Form. See the sample code.

com.sun.lwuit.Form lwuitForm;
protected void startApp() throws MIDletStateChangeException {
    Display.init(this);
    lwuitForm = new com.sun.lwuit.Form("LWUIT Form");
    lwuitForm.addComponent(new TextField(""));

    final MIDlet midlet = this;
    final Command abtUsCmd = new Command("Next") {
        public void actionPerformed(ActionEvent evt) {
            javax.microedition.lcdui.Form  frm = new javax.microedition.lcdui.Form("LCDUI Form");
            StringItem item = new StringItem("Text", "Sample text");
            frm.append(item);

            final javax.microedition.lcdui.Command cmd = new javax.microedition.lcdui.Command("Back", javax.microedition.lcdui.Command.BACK, 0);
            CommandListener cmdLis = new CommandListener() {

                public void commandAction(javax.microedition.lcdui.Command c, Displayable d) {
                    if(c == cmd) {
                        Display.init(midlet);
                        lwuitForm.show(); // Show the LWUIT form again
                    }
                }
            };

            frm.setCommandListener(cmdLis);
            frm.addCommand(cmd);

            javax.microedition.lcdui.Display.getDisplay(midlet).setCurrent(frm); // show the LCDUI Form
        }
    };
    lwuitForm.addCommand(abtUsCmd);
    lwuitForm.show(); // Show the LWUIT Form
}
Char2674
  • 93
  • 9
bharath
  • 13,880
  • 16
  • 53
  • 93
  • is it possible to set background LWUIT theme and set lcdui form on the top of it.....??? – Abdullah Md. Zubair Jul 12 '11 at 05:33
  • AFAIK its not possible. you are not able use both at the same time. – bharath Jul 12 '11 at 05:34
  • can we call lwuit form on top of the lcdui form? meaning i have a lcdui app and i want to just use a component (say `HtmlComponent`) from LWUIT.. so cant i make the form and show it from the current LCDUI form? – Nezam Feb 15 '13 at 09:31
1

This looks tricky, but yeah, we can switch between both. The trick is when u show the LWUIT form, after it has been successfully painted on the screen, make a call to

javax.microedition.lcdui.Display.getDisplay(midlet).getCurrent();

this gives you the Displayable holding all the LWUIT views, so with this, you can always switch to LCDUI, and back to LWUIT with the LCDUI's

display.setCurrent

Let me know if this works for you. Thanks

Kingsley Adio
  • 718
  • 5
  • 15