2

I added 2 commands to my form in lwuit.

form.addCommand(test);
form.setBackCommand(exitCommand);

I changed the command behavior to COMMAND_BEHAVIOR_NATIVE, so i can show the status, and my commands appear at the bottom too, but they appear exit at the right ..and test Command in the middle. I want to show only 2 commands layout in the menu bar, Exit on the right and options list that contains test on the left. How can i do that?

Mun0n
  • 4,438
  • 4
  • 28
  • 46
Reham
  • 1,916
  • 6
  • 21
  • 45

2 Answers2

1

First get the back Command and remove it. After this, add the exit Command like a standard Commandwith addCommand. Try this, if this doesn´t work we can try something else.

Mun0n
  • 4,438
  • 4
  • 28
  • 46
  • Ok i'll try it,but how can i get the J2ME Native Back Command, for lwuit i used form.removeCommand(form.getMenuBar().getBackCommand()); But i must remove the Native one. – Reham Oct 21 '12 at 06:17
  • Jmunoz,,thank you for your help, but i guess form.getback command will get the lwuit one ,,,so it will not be removed from the menu..:( – Reham Oct 21 '12 at 16:52
  • it takes the default back Command...are you using a custom back command? http://lwuit.java.net/javadocs/com/sun/lwuit/Form.html#getBackCommand() – Mun0n Oct 21 '12 at 18:06
  • I'm using this form.setBackCommand(exitCommand); As i said before..it is not custom..but i think since i changed the Command Behavior to Native..this will not take an effect – Reham Oct 21 '12 at 18:11
  • So i did the fowlloing. form.removeCommand(form.getBackCommand()); form.addCommand(test); form.addCommand(exitCommand); I got an option command holding the 2 other commands.. – Reham Oct 21 '12 at 18:27
  • The same Result.. form.removeAllCommands(); form.addCommand(test); form.addCommand(exitCommand); – Reham Oct 21 '12 at 18:40
  • Do something similar with the MenuBar object... http://lwuit.java.net/javadocs/com/sun/lwuit/MenuBar.html – Mun0n Oct 21 '12 at 18:42
0

I don't know about LWUIT since I've never used it, but with native JavaME you sadly have no control of this. It is the individual device that decides where to place the commands.

You can move them around by changing the priority parameter, and you may be able to achieve an acceptable result that way, but only on some devices. The same code will give a different result on other devices.

mr_lou
  • 1,910
  • 2
  • 14
  • 26
  • Thank you for your answer, but i must find a way to do that. Can i remove those commands?and build a new custom bar. – Reham Oct 19 '12 at 18:18