2 Replies Latest reply: Sep 12, 2009 9:13 AM by 843810 RSS

    JOptionPane buttons in English and in another language?

    843810
      How do I change the language of the buttons in JOptionPane.showInputDialog?

      When I use the Traditional Chinese Windows, I see Chinese characters in the buttons.

      Can I have buttons in English even if I use the Traditional Chinese Windows? How? What web pages should I consult?
       Locale locale = Locale.getDefault();
      
          locale = new Locale("en", "US");
          Locale.setDefault(locale);
      does not help me to get the correct human language I prefer, e.g. on the confirm button.

      Edited by: tse2009 on Sep 12, 2009 6:22 AM
        • 1. Re: JOptionPane buttons in English and in another language?
          843810
          Finally, I searched the web and got some ideas from:

          [http://jackywu1978.javaeye.com/blog/forum/97|http://jackywu1978.javaeye.com/blog/forum/97]

          Then, I can get the preferred language on the buttons on JOptionPane.
          import sun.awt.AppContext;
          
          public class getTheRightLanguagePreferred{
           Locale locale = Locale.getDefault();
          
              locale = new Locale("en", "US");
              Locale.setDefault(locale);
          AppContext.getAppContext().put("JComponent.defaultLocale", locale);
          }
          If you think that it is useful, please comment.
          • 2. Re: JOptionPane buttons in English and in another language?
            843810
            It took me more than 45 minutes to search for the correct solution using Google and Baidu. Maybe this is "normal" for new Java programmers like me.

            Edited by: tse2009 on Sep 12, 2009 7:12 AM