问题
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:
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)
来源:https://stackoverflow.com/questions/6938731/lwuit-localize-menubar