Ayvadia
Ayvadia

Reputation: 339

Coding a menu that allows user to select a language

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;
    }

Upvotes: 1

Views: 849

Answers (1)

padde
padde

Reputation: 661

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

Upvotes: 1

Related Questions