LWUIT Localize MenuBar

巧了我就是萌 提交于 2019-12-24 07:38:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!