×

Discussion Board

Results 1 to 8 of 8

Thread: j2me

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    24

    j2me

    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??

  2. #2
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: j2me

    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.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    24

    Re: j2me

    please can u send me sample code ar ramesh.v@ideabytes.ca

  4. #4
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: j2me

    Hi,
    Below is a simple MIDlet which has one form of Lcdui and one form of Lwuit.
    Hope this helps.

    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);
    	}
    
    }
    -Roopesh.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    24

    Re: j2me

    Thanks alot roopesh.

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    24

    Re: j2me

    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

  7. #7
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: j2me

    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.

  8. #8
    Registered User
    Join Date
    Jan 2009
    Posts
    1

    Re: j2me

    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!.

    Code:
    com.sun.lwuit.Display.deinitialize();
    javax.microedition.lcdui.Display.getDisplay(this).setCurrent(lcduiForm);
    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.init(this);
    lwuitForm.show();

Similar Threads

  1. J2ME or C++ for VoIP on Mobile
    By sandeepkumar03 in forum VoIP
    Replies: 4
    Last Post: 2009-02-02, 10:28
  2. Calling a native c or c++ application from J2ME
    By satyarajasekhar in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2009-01-02, 12:10
  3. J2ME or C++ for VoIP on Mobile Phone
    By sandeepkumar03 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-11-13, 20:14
  4. Acessing voice channel using J2ME
    By diegomello in forum VoIP
    Replies: 1
    Last Post: 2008-10-21, 15:57
  5. Can J2ME be used for sending MMS Message ?
    By seno_ap in forum Mobile Java General
    Replies: 1
    Last Post: 2006-11-24, 14:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×