wood burning stoves*
The moose likes Java Micro Edition and the fly likes Controlling appearance of popup menu with Command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Controlling appearance of popup menu with Command" Watch "Controlling appearance of popup menu with Command" New topic
Author

Controlling appearance of popup menu with Command

Victor Ho
Ranch Hand

Joined: Sep 05, 2003
Posts: 74
Hi,

Is there some easy way to have better control on the pop-up menu display with using Command on a Form?

e.g.
(Left softkey button):
List
-> L_action1
-> L_action2
-> L_action3

(Right softkey button):
Call
-> C_action1
-> C_action2

addCommand(new Command("List", Command.SCREEN, 1));
addCommand(new Command("Call", Command.SCREEN, 1));

addCommand(new Command("L_action1", Command.SCREEN, 2));
addCommand(new Command("L_action2", Command.SCREEN, 2));
addCommand(new Command("L_action3", Command.SCREEN, 2));

addCommand(new Command("C_action1", Command.SCREEN, 3));
addCommand(new Command("C_action2", Command.SCREEN, 3));


The above code didn't work, and playing with the prority and commandType also didn't help much. In particular, is it possible to group a list of options under a menu easily?

Thanks
Victor
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well, when you are using the high level UI APIs, you have zero control in how it looks on the device, that is what the high level API is about, making the device be responsible for making it display in a nice mamner but device specific way.

You can use something like J2ME Polish to make a prettier UI.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
William Frantz
Ranch Hand

Joined: Dec 08, 2004
Posts: 102
There is no sense naming multiple commands with the same priority.

For example, assume a device has two softkeys and you want to display 4 commands. It should put the highest ranked command on one of the softkeys. The other key will display something like "menu" where the remaining 3 commands will appear.

Move that same application to a three softkey device and commands 1 and 2 will be visible while 3 and 4 will be under one key called "menu".

It's also possible that the JVM will simply ignore the priorities and put all the commands under a single "menu" key.

All of the above is purely conjecture on what is likely. As Mark pointed out, it's really up to the JVM and there are no guarantees.

I usually make a "static final" called lowPriority and set it to 99. Then I make a highPriority set to 1. When I start defining commands I use expressions like highPriority, highPriority+1, highPriority+2, or lowPriority, lowPriority-1, lowPriority-2, etc.

William Frantz
http://sprintdevelopers.com
 
Don't get me started about those stupid light bulbs.
 
subject: Controlling appearance of popup menu with Command
 
Similar Threads
IllegalStateException
Puzzled by the behaviour
my .jar didn't run well
HELP!! I can't see my picture
Command listenr