tags:

views:

82

answers:

1

As part of a college project we are localising our application.

Is it possible to localise swing components such as JOptionPane and if so how?

+1  A: 

You can use ResourceBundle for localization in general (in option pane case for the choise strings and messages) . Then you can use those localized Strings etc for the JOptionPane. For example:

String[] choises = new String[];
choises[0] = bundle.getString("yes");
choises[1] = bundle.getString("no");
choises[2] = bundle.getString("cancel");

String message = bundle.getString("messageText")

JOptionPane optionPane = new JOptionPane(message, JOptionPane.WARNING_MESSAGE,
        JOptionPane.YES_NO_CANCEL_OPTION, null, choises);

For more details for resource bundles check out Java Internationalization: Localization with ResourceBundles.

Touko