• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Canvas or Form for startup screen

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have a startup screen. Where there are two options. 1 for the app 2 for setting preferences. Right now I have the app main form start and there is two commands on the right button, so it automatically creates the right button to be a menu. I don't want this, because I want the app main form to have an Exit or Back as the left button, and "Calculate" as the right button. But now the user will have to select the menu, then select the "Calculate" option from the menu, or select the "Set Preferences" option to go there.
Here I am thinking, why not have a startup screen? I can have the name of the application, and image, then a mini on-screen menu with the two options. 1 - go to calculator, and 2 - set preferences. By making this a Canvas, I can catch the KeyReleased button, and go to the appropriate form from there. If I made this a Form then I would need to have a TextField to catch the users choice, which I think is a little hokey.
So now if I have the startup canvas, and the user hits a key, how do I then go to the form of their choice. I also want clean code, meaning the Canvas shouldn't know the other forms, the Midlet will know these forms.
Thanks for any suggestions you might have.
Mark
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
The way I do this is to a static controller class that dispatches all the screen changes. The MIDlet class itself is merely an instrument to load the controller. The MVC pattern -- so overused in the web context -- was originally designed for rich client UI applications and fits perfectly here.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael. That sounds like a good idea.
By any chance do you have any sample code that can demonstrate this. Just a simple example of the Static class, and an example of a method in the MIDlet using that class.
Thanks
Mark
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm, I wish Nokia would publish my new article on this very topic soon ... But while we are waiting, the Sun J2ME Blueprint (Smart Ticket) offers a good example of the MVC pattern. Check out an analysis article I co-authored about 6 months ago:
End-to-End J2ME Application Development by Example - Introducing Smart Ticket
The article refers to the early release version of smart ticket (for JavaOne). They might have pulled the code from their web site. But I have a copy of the code available from my site here
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael. The example will help a lot.
Mark
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,

To overcome the initial problem you had (that is, both commands appearing on the pop-up menu of one button), you could try giving the two commands different types.

For example, this works on a lot of Nokia phones:

commandLeft = new Command("Left", Command.SCREEN, 0);
commandRight = new Command("Right", Command.BACK, 0);

so when you add these commands to a screen, one appears on the left, the other on the right - i.e., no pop-up menu!
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks James, that is a good idea. I have already completed the project, and just included the two options as text on the Canvas that captures the keypressed. It works perfectly.

Thanks

Mark
 
Water! People swim in water! Even tiny ads swim in water:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic