import javax.microedition.lcdui.*;
import com.sun.lwuit.*;
can i include this two packages at a time ...to include this two packages what should i do??
import javax.microedition.lcdui.*;
import com.sun.lwuit.*;
can i include this two packages at a time ...to include this two packages what should i do??
Yes. You can use both LCDUI and LWUIT forms in your application.
I have recently worked on changing forms from LCDUI to LWUIT. While one form in chaged from to LWUIT others were still kept in LCDUI. (Just to go step by step).
And it worked perfectly fine.
Regards,
Roopesh.
please can u send me sample code ar ramesh.v@ideabytes.ca
Hi,
Below is a simple MIDlet which has one form of Lcdui and one form of Lwuit.
Hope this helps.
-Roopesh.Code:import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import com.sun.lwuit.Label; import com.sun.lwuit.events.ActionEvent; import com.sun.lwuit.events.ActionListener; public class LcduiWithLwuit extends MIDlet implements CommandListener, ActionListener { private Form form = new Form("LCDUI"); private Command swap = new Command("Swap", Command.OK, 1); private com.sun.lwuit.Command swap2 = new com.sun.lwuit.Command("Swap"); private com.sun.lwuit.Form form2; public LcduiWithLwuit() { form.append("You are in LCDUI"); form.addCommand(swap); form.setCommandListener(this); Display.getDisplay(this).setCurrent(form); com.sun.lwuit.Display.init(this); form2 = new com.sun.lwuit.Form("LWUIT"); form2.addComponent(new Label("You are in LWUIT")); form2.addCommand(swap2); form2.addCommandListener(this); } protected void destroyApp(boolean arg0) throws MIDletStateChangeException { // TODO Auto-generated method stub } protected void pauseApp() { // TODO Auto-generated method stub } protected void startApp() throws MIDletStateChangeException { // TODO Auto-generated method stub } public void commandAction(Command c, Displayable d) { form2.show(); } public void actionPerformed(ActionEvent evt) { Display.getDisplay(this).setCurrent(form); } }
Hii roopesh ur code is working fine in wireless tool kit. but when i am try to runnig the same code in NetBeans i am getting the below error
Error preverifying class com.sun.jwt.resource.util.BlockingAction$1
java/lang/NoClassDefFoundError: javax/swing/JComponent
C:\Documents and Settings\ramesha\My Documents\NetBeansProjects\Image1\nbproject\build-impl.xml:461: Preverification failed with error code 1.
please any one help me
Hi ramcsdp07,
I have never worked with NetBeans. So, Do not know whats happening.
But my guess is, you might have forgot to add LWUIT Library (add external jar option) into into your jar file.
But, I suggest this,
*) First create a MIDlet with LCDUI form only. Run it.
*) If you are successful, create a MIDlet with LWUIT form only. Run it.
*) If you are successful, try merging both.
-Roopesh.
roopesh.kumar's code snippet is true but need a small thing to be added. Lets assume you are switching LWUIT -> LCDUI -> LWUIT, in such a case before calling Display.getDisplay(this).setCurrent(form); call com.sun.lwuit.Display.deinitialize();. Otherwise will get an exception saying Attempting to push Screen while alreadydisplayed!.
And also before displaying LWUIT Form, re-call com.sun.lwuit.Display.init(this);. This works for me fine when integrating LCDUI Camera on an LWUIT project.Code:com.sun.lwuit.Display.deinitialize(); javax.microedition.lcdui.Display.getDisplay(this).setCurrent(lcduiForm);
Code:com.sun.lwuit.Display.init(this); lwuitForm.show();