Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Canvas or Form for startup screen

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael. The example will help a lot.
Mark
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic