×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    how to combine eSWT display & javax.microedition.lcdui.Display

    Hello Friends.,
    last few days i'm working on eSWT lib.

    i want to use both display class 1 is eSWT & another is javax.microedition.lcdui.Display

    how i can switch in between display..,,

    i tried but my app get crash or giving error
    "java.lang.RuntimeException: Only one UI toolkit can be used at a time."

    please tell me how i can do this .......?
    thanks & Regards.
    Nilesh

  2. #2
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    Hi nyerunkar,

    As exception says you can't use two toolkits together.

  3. #3
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    thanks for your reply ..
    but how i can do this ... ?
    thanks & Regards.
    Nilesh

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    Hi nyerunkar,

    To be more precise, it is possible to switch from an eSWT UI to an LCDUI Display by using this code (tested on Nokia 701):

    Code:
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.*;
    
    import org.eclipse.ercp.swt.mobile.Command;
    import org.eclipse.swt.events.*;
    import org.eclipse.swt.widgets.*;
    
    public class eSWT2FormMIDlet 
    	extends MIDlet 
    	implements SelectionListener, Runnable, CommandListener {
    
    	// The eSWT Display created by this MIDlet in the eSWT UI thread.
    	// When this is created the MIDlet gets connected to the native UI
    	// functionality and eSWT UI toolkit is initialised for it. 
    	private Display display;
    	// A Shell widget created by this MIDlet. 
    	private Shell shell;
    	// A boolean to set when the event loop should exit. 
    	private boolean exiting = false;
    	private Thread uiThread;
    	javax.microedition.lcdui.Command lcduiExit;
    	Command backCommand;
    
    	public void startApp() {
    		if(uiThread == null) {
    			uiThread = new Thread(this);
    			uiThread.start();
    		}       
    	}
    
    	public void pauseApp() {
    		// Here we could reduce the resources but we should keep the Display 
    		// instance and the eSWT UI Thread. 
    	}
    
    	public void destroyApp(boolean unconditional) {
    		// Make the event loop exit in the eSWT UI thread.
    		exitEventLoop();
    		// Wait for the eSWT UI thread to die. 
    	}
    
    	// This method can be called from any thread to make the event loop to exit. 
    	void exitEventLoop() {
    		exiting = true;
    		Display.getDefault().wake();    
    	}
      
    
    	public void widgetDefaultSelected(SelectionEvent e) {
    	
    	}
    
    	public void widgetSelected(SelectionEvent e) {
    		exitEventLoop();
    	}
    
    	public void run() { 
    		display = new Display();
    		shell = new Shell(display);
    		shell.open();	    
    	   
    	    backCommand = new Command(shell, Command.BACK, 1);
            backCommand.setText("Back");
            backCommand.addSelectionListener(this);
            
    	    // Execute the eSWT event loop. 
    	    while(!exiting) {
    	      if(!display.readAndDispatch()) {
    	        display.sleep();
    	      }
    	    }
    	    
    	    // Clean up and destroy the MIDlet.
    	    display.dispose();
    	   javax.microedition.lcdui.Display lcduiDisplay = javax.microedition.lcdui.Display.getDisplay(this);
    	   
    	   Form lcduiForm = new Form("LCDUI Form");
    	   lcduiForm.append("This is an LCDUI Component");
    	   lcduiExit = new javax.microedition.lcdui.Command("Exit", Command.OK, 1);
    	   lcduiForm.addCommand(lcduiExit);
    	   lcduiForm.setCommandListener(this);
    	   lcduiDisplay.setCurrent(lcduiForm);
    	
    	}
    
    	public void commandAction(javax.microedition.lcdui.Command c,
    			Displayable arg1) {
    		if(c == lcduiExit) {
    			notifyDestroyed();
    		}
    		
    	}
    }
    Switching from an LCDUI MIDlet to an eSWT widget is not feasible, because if you get the display of the MIDlet by using this code:

    Code:
     Display.getDisplay(this)
    the widget's display will fail to register at any point after that. Switching from eSWT to LCDUI is possible because the UI thread that handles the display of the widget stays alive after the disposal of the Display instance (there is only one Display instance per MIDlet). However I don't see how the LCDUI MIDlet can stay alive without its Display instance, so that it can call the eSWT widget.

  5. #5
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    thanks skalogir for reply ...

    but its not working i'm using nerbean 6.9 nokia s60 3rd FP2 sdk
    thanks & Regards.
    Nilesh

  6. #6
    Regular Contributor
    Join Date
    Jan 2004
    Posts
    125

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    Hi,

    Why do you need eSWT and LCDUI ? eSWT is more powerfull than LCDUI ! Perhaps you want to use the GameCanvas ?

    Thanks

  7. #7
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    Quote Originally Posted by frasene View Post
    Hi,

    Why do you need eSWT and LCDUI ? eSWT is more powerfull than LCDUI ! Perhaps you want to use the GameCanvas ?

    Thanks
    my friend i know eSWT powerfull than LCDUI ... but i want both coz i made my whole project in LCDUI... only for broswer i need to used eSWT ...
    thanks & Regards.
    Nilesh

  8. #8
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    Hi nyerunkar,

    I compiled the code with Symbian Belle SDK 1.0. What device are you testing this on?

  9. #9
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    I'm working on nokia SDK S60 5th Edition ...
    thanks & Regards.
    Nilesh

  10. #10
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    Unfortunately this kind of display switch is only supported on devices running Symbian^3, Symbian Anna or Nokia Belle

  11. #11
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    i'm trying on symbian s60 3rd Edition ..still its not working ...........
    thanks & Regards.
    Nilesh

  12. #12
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    The order of Symbian platforms (latest to oldest) is this:

    Nokia Belle
    Symbian Anna
    Symbian^3

    S60 5th Edition
    S60 3rd Edition Feature Pack 2
    S60 3rd Edition Feature Pack 1
    S60 3rd Edition (initial release)

    The sample code I provided can only work on the platforms in Bold. S60 5th Edition and S60 3rd Edition devices, being older, do not support the combination of an eSWT and LCDUI Display. If you are uncertain about which devices support the platforms in bold, please check this link

  13. #13
    Registered User
    Join Date
    Jun 2010
    Location
    India
    Posts
    200

    Re: how to combine eSWT display & javax.microedition.lcdui.Display

    Thanks skalogir for reply.

    i'm working on S60 3rd above version ....
    thanks & Regards.
    Nilesh

Similar Threads

  1. javax.microedition.lcdui.TextField not displayed on E75
    By javanerd.com.au in forum Mobile Java General
    Replies: 1
    Last Post: 2009-11-12, 06:35
  2. S40 SDK cannot access javax.microedition.lcdui.ChoiceVector
    By nicholso in forum Mobile Java General
    Replies: 10
    Last Post: 2009-01-02, 13:33
  3. Program closed:!jes-0-javax.microedition.lcdui@ad...
    By M.Carbone in forum Mobile Java General
    Replies: 0
    Last Post: 2008-02-16, 21:31
  4. App Closed javax.microedition.lcdui...
    By jinesh_l in forum Mobile Java General
    Replies: 3
    Last Post: 2005-09-10, 13:53
  5. App.closed jes-67f-javax.microedition.lcdui@1
    By abhiauradkar in forum Mobile Java General
    Replies: 0
    Last Post: 2003-12-23, 08:56

Posting Permissions

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