×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Series 40 app display, duplicate screen

    Hi,
    I'm on a way to develop J2ME app with S40 series but i have some problems with the screen duplicate.

    Detail : I just use Forms and i display images and stringItems. With the emulator it works fine until i click and move the cursor in this case my menu disappear.
    Once upload in the device (tested on Nokia C3-00) the menu dont appear well only last string is displayed.

    Please help me. If you need more details about it i can give it.

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

    Re: Series 40 app display, duplicate screen

    Hi,

    Can you please provide a code sample, as well as the version of the SDK you are testing with? What do you mean by "click and move the cursor"? Do you have a TextField attached to your form, where you try to move the cursor by using the phone's left/right physical keys?

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: Series 40 app display, duplicate screen

    it happen in my main screen. code below :

    package view;

    import OrderMIDlet;

    import java.io.IOException;

    import java.util.Date;
    import java.util.Vector;

    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.StringItem;

    import model.Business;
    import model.Order;

    public class MainScreen extends Form implements CommandListener {

    private StringItem numUrgentOrders;
    private StringItem moneyExpected;
    private StringItem moneyReceived;
    private StringItem nbOrders;

    private Image imgDefarlou;

    private Command cmdNewOrder, cmdExit;
    private Command cmdReset;
    private Command cmdSmsAssociate;
    private Command cmdHelp;
    private Command cmdAbout;
    private Command cmdListOrders;

    public static long TWODAYSINMS = 2 * 24 * 60 * 60 * 1000;

    public MainScreen() {

    super("Défarlou");

    this.append("\n");

    try {
    imgDefarlou = Image.createImage("/greendollarstiny.jpg");
    this.append(imgDefarlou);
    } catch (IOException e) {
    e.printStackTrace();
    }

    moneyReceived = new StringItem("", "Paid: "
    + Business.getInstance().getMoneyPaid(), StringItem.PLAIN);
    this.append(moneyReceived);

    this.append("\n");

    try {
    imgDefarlou = Image.createImage("/reddollarstiny.jpg");
    this.append(imgDefarlou);
    } catch (IOException e) {
    e.printStackTrace();
    }

    moneyExpected = new StringItem("", "Owed: "
    + Business.getInstance().getMoneyExpected(), StringItem.PLAIN);
    this.append(moneyExpected);

    this.append("\n");

    // **********************************************tester
    // Put the orders in the list to urgent if they need to - with respect
    // to the ordered date (not the date of today)

    Vector nowOrders = Business.getInstance().getOrdersList();

    // CHECK pour compter le nombre de orders qui sont urgents
    int counter = 0;

    for (int i = 0; i < nowOrders.size(); i++) {
    Order traceOrder = (Order) nowOrders.elementAt(i);

    long dueTimeMilliSeconds = traceOrder.getDueDate().getTime();
    long orderedTimeMillisSeconds = traceOrder.getOrderedDate()
    .getTime();

    Date today = new Date();
    long todayMilliSeconds = today.getTime();
    if (dueTimeMilliSeconds - todayMilliSeconds < TWODAYSINMS) {
    traceOrder.setUrgent(true);
    if (!traceOrder.isDone()) {
    counter = counter + 1;
    }
    System.out.println("order at position " + i + " is urgent");
    } else {
    System.out.println("order at position " + i + " is not urgent");
    }
    }

    Business.getInstance().setNbUrgentOrders(counter);

    try {
    imgDefarlou = Image.createImage("/defarloutiny.jpg");
    this.append(imgDefarlou);
    } catch (IOException e) {
    e.printStackTrace();
    }

    nbOrders = new StringItem("", Business.getInstance().getNbOrders()
    + " orders\n", StringItem.PLAIN);
    this.append(nbOrders);

    try {
    imgDefarlou = Image.createImage("/sirentiny.jpg");
    this.append(imgDefarlou);
    } catch (IOException e) {
    e.printStackTrace();
    }

    // numUrgentOrders = new StringItem("", Business.getInstance()
    // .getNbUrgentOrders() + " urgent orders\n");
    // this.append(numUrgentOrders);

    numUrgentOrders = new StringItem("", counter + " urgent orders\n",
    StringItem.PLAIN);
    this.append(numUrgentOrders);

    this.cmdNewOrder = new Command("New", Command.SCREEN, 0);
    this.addCommand(cmdNewOrder);

    this.cmdListOrders = new Command("Orders", Command.SCREEN, 1);
    this.addCommand(cmdListOrders);

    // this.cmdCalendar = new Command("Calendar", Command.SCREEN, 2);
    // this.addCommand(cmdCalendar);

    this.cmdSmsAssociate = new Command("SMS to manager", Command.SCREEN, 3);
    this.addCommand(cmdSmsAssociate);

    this.cmdReset = new Command("Reset", Command.SCREEN, 4);
    this.addCommand(cmdReset);

    this.cmdHelp = new Command("Help", Command.SCREEN, 5);
    this.addCommand(cmdHelp);

    this.cmdAbout = new Command("About", Command.SCREEN, 6);
    this.addCommand(cmdAbout);

    this.cmdExit = new Command("Exit", Command.EXIT, 7);
    this.addCommand(cmdExit);

    this.setCommandListener(this);
    }

    public void commandAction(Command cmd, Displayable d) {
    if (cmd == this.cmdExit) {
    OrderMIDlet.getInstance().exitNow();
    return;
    } else if (cmd == this.cmdNewOrder) {
    OrderMIDlet.getInstance().setCurrentScreen(new NewOrderScreen());
    } else if (cmd == this.cmdListOrders) {
    OrderMIDlet.getInstance()
    .setCurrentScreen(new ListOrdersScreen(""));
    } else if (cmd == this.cmdSmsAssociate) {
    OrderMIDlet.getInstance().setCurrentScreen(new SMSManagerScreen());
    } else if (cmd == this.cmdReset) {
    OrderMIDlet.getInstance().setCurrentScreen(new RazScreen());
    } else if (cmd == this.cmdHelp) {
    OrderMIDlet.getInstance().setCurrentScreen(new HelpScreen());
    } else if (cmd == this.cmdAbout) {
    OrderMIDlet.getInstance().setCurrentScreen(new AboutScreen());
    }
    }

    }



    When i run emulator it seems like a can swich the screen by clickin down arrow. In this way only last StringItem "URgent Order" appear.

    in the device i already have this last stringItems and relate image. other strings are nor displayed but images related to this stringItems appear.

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

    Re: Series 40 app display, duplicate screen

    If I understand correctly, your UI is displaying an icon/image along with some text, when creating a selectable option.

    You can see the classes that support images here:
    http://library.developer.nokia.com/i...E924A7B60.html

    For your case, I believe the most appropriate classes are:

    List:
    http://library.developer.nokia.com/i...207BE4096.html

    ChoiceGroup:
    http://library.developer.nokia.com/i...D32701187.html

    A sample code of your UI, without the underlying functionality, with a List implementation is this:
    Code:
    import java.io.IOException;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.List;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    public class OrderMIDlet extends MIDlet implements CommandListener 
    {
    	private String numUrgentOrders;
    	private String moneyExpected;
    	private String moneyReceived;
    	private String nbOrders;
    	private Image imgDefarlou;
    	private Image imgDefarli;
    	private Image imgDefarlo;
    	private Image imgDefarla;
    	private Command cmdExit;
    	private List ls;
    
    	public OrderMIDlet() 
    	{
    		ls=new List("My Items",List.IMPLICIT);
    		try 
    		{
    			imgDefarlou = Image.createImage("/greendollar.jpg");
    		} catch (IOException e) {
    			e.printStackTrace();
    		}				
    		moneyReceived = "Option 1";
    		ls.insert(0, moneyReceived, imgDefarlou);
    		
    		try {
    			imgDefarli = Image.createImage("/reddollar.jpg");
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		moneyExpected = "Option 2";
    		ls.insert(1,moneyExpected,imgDefarli);
    
    		try 
    		{
    			imgDefarlo = Image.createImage("/money.jpg");
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		nbOrders = "Option 3";
    		ls.insert(2, nbOrders , imgDefarlo);		
    		
    		try 
    		{
    			imgDefarla = Image.createImage("/honey.jpg");
    		} catch (IOException e) 
    		{
    			e.printStackTrace();
    		}
    		numUrgentOrders = "Option 4";
    		ls.insert(3, numUrgentOrders, imgDefarla);
    		
    		this.cmdExit = new Command("Exit", Command.EXIT, 7);
    		ls.addCommand(cmdExit);
    
    		ls.setCommandListener(this);
    	}
    	public void commandAction(Command cmd, Displayable d) {
    		if (cmd == this.cmdExit) 
    		{
    			notifyDestroyed();
    		} 
    	}
    	protected void destroyApp(boolean unconditional)
    			throws MIDletStateChangeException {		
    	}
    	protected void pauseApp() {		
    	}
    	protected void startApp() throws MIDletStateChangeException {
    		Display.getDisplay(this).setCurrent(ls);	
    	}
    }

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: Series 40 app display, duplicate screen

    It is possible to join a screenshot here or some where in the forum to let you see what really happen when i run my app.

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

    Re: Series 40 app display, duplicate screen

    Hi noumounthi,

    You don't need to attach a screenshot here since the behavior you are experiencing is expected. The problem is that you are appending 4 images on your form, while you can only append one image per form:

    http://library.developer.nokia.com/i...cdui/Form.html

    What you can do, if you see the link I provided in my previous post, is to use an ImageItem, a List or a ChoiceGroup for image display.

    Now, depending on how you want to display your information on the screen you have the following options:

    1. Try to create an ImageItem for each image and append the ImageItem, not the Image itself to the form.

    More information regarding ImageItems:
    http://library.developer.nokia.com/i...ImageItem.html

    2. You can directly insert the Image to a List or a ChoiceGroup (as in the code I have provided), but you have to drop using your form.
    More information about Lists and ChoiceGroups:

    http://library.developer.nokia.com/i...oiceGroup.html
    http://library.developer.nokia.com/i...cdui/List.html

    It really depends on how you want to display the images and the text on your screen.

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Re: Series 40 app display, duplicate screen

    thank's a lot it works well when i use list as you tell me . I'll deploy it and run in my Nokia. I'll tell you more about it. Thanks again.

Similar Threads

  1. Duplicate HttpConnection POST on Series 40
    By batkinson in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2010-08-12, 23:28
  2. Replies: 0
    Last Post: 2010-03-14, 08:45
  3. Replies: 3
    Last Post: 2009-03-31, 12:05
  4. Duplicate Item In List Display
    By jaceline in forum Personal Profile
    Replies: 2
    Last Post: 2006-06-06, 02:06
  5. Replies: 1
    Last Post: 2005-11-26, 19:08

Posting Permissions

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