jQuery in Action, 3rd edition
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
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

Controlling appearance of popup menu with Command

Victor Ho
Ranch Hand

Joined: Sep 05, 2003
Posts: 74

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

(Left softkey button):
-> L_action1
-> L_action2
-> L_action3

(Right softkey button):
-> 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?

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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.


Perfect World Programming, LLC - iOS Apps
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
I agree. Here's the link: http://aspose.com/file-tools
subject: Controlling appearance of popup menu with Command
It's not a secret anymore!