Coding a menu that allows user to select a language

…衆ロ難τιáo~ 提交于 2019-12-11 12:17:16

问题


How would I go about coding a menu that will allow the user to select a language and thereafter the user will have his whole program rendered in the language of his choice?

Note: I'm using Netbeans and one of the tutorials suggested using automatic internalization to make the bundle.properties files.

What I don't know is how to set the language to selected option.
Please explain in detail as I can barely understand what I'm doing right now.

int sel = cmbLang.getSelectedIndex();
    switch (sel) {
        case 0:
            JOptionPane.showMessageDialog(null,"please make a selection");
            break;
        case 1:
            fmt:setLocale(Locale.E);//set language to language 1 
            break;
        case 2:
            //set Language to language 2
            break;
    }

回答1:


As suggested here you could use Locale.setDefault(Locale yourDesiredLocale)(see Javadoc) to change the language.



来源:https://stackoverflow.com/questions/19067918/coding-a-menu-that-allows-user-to-select-a-language

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