LWUIT Localize MenuBar

2019-07-24 21:29发布

I'd like to localize the MenuBar of an LWUIT form.

I don't want to show the users "Menu" / "Select" / "Cancel".

I've successfully localized single commands, which get shown when the Menu opens, via

back.setCommandName("bk");
searchCommand.setCommandName("search");
exit.setCommandName("ex");

mainMenu.addCommand(back, 0);
mainMenu.addCommand(searchCommand, 1);
mainMenu.addCommand(exit, 2);

For the MenuBar I tried

MenuBar m = NameOfMyForm.getMenuBar();

m.setName("test");
mainMenu.setMenuBar(m);

But this didn't work - also this wouldn't give me access to "Select" and "Cancel".

1条回答
Viruses.
2楼-- · 2019-07-24 22:26

Use setResourceBundle() method. See the code for change the menu, select and cancel command captions.

Hashtable hashtable = new Hashtable();
hashtable.put("select", "your caption");
hashtable.put("cancel", "your caption");
hashtable.put("menu", "your caption");
UIManager.getInstance().setResourceBundle(hashtable);

Suppose if you want to use image for these commands means use setMenuIcons method,

UIManager.getInstance().getLookAndFeel().setMenuIcons(Image select, Image cancel, Image menu)
查看更多
登录 后发表回答