title: Swing Internationalization - How to update language at runtime
body: <p>I've followed <a href="https://developers.google.com/java-dev-tools/wbpro/features/internationalization" rel="nofollow noreferrer">Googles howto for its Window Builder Pro extension</a> to internationalize my app. Strings that will be shown in labels are now stored in property-files that were created by the "Externalize Strings" wizard (I've used classic eclipse message files).</p>
  
  <p>Inside my <code>initialize</code> method, all my lables are initialized and their text is set like this:</p>
  
  <pre><code>JLabel lblLanguage = new JLabel(Messages.getString("App.lblLanguage.text")); //$NON-NLS-1$
  </code></pre>
  
  <p>I have created an enum type inside my class <code>App</code> which holds the GUI:</p>
  
  <pre><code>private enum Lang { German(Locale.GERMAN), English(Locale.ENGLISH);
  
      private Locale loc;
      Lang (Locale l) {
          loc = l;
      }
  
      Locale getLocale() {
          return loc;
      }
  }
  </code></pre>
  
  <p>The language will be set with a combobox that uses the enum type Lang to show the languages available:</p>
  
  <pre><code>    JComboBox cboLanguage = new JComboBox();
      cboLanguage.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              JComboBox cb = (JComboBox)e.getSource();
              Lang l = (Lang)cb.getSelectedItem();
              // TODO: update language
          }
      });
      cboLanguage.setModel(new DefaultComboBoxModel(Lang.values()));
  </code></pre>
  
  <hr>
  
  <p>I've found many other howtos and tutorials covering the internationalization of swing applications but none of them covers how to update all labels (and possible other controls with text in them). There's <a href="https://stackoverflow.com/a/3339773/698583">this answer</a> here on SO that might have been helpful if the links weren't dead.<br>
  Because I'm kind of new to GUI programming in java, I don't really know what to do now and here are my questions:</p>
  
  <ul>
  <li>What is the best way, to change the language of all controls at runtime if a new language is set?</li>
  <li>Is it ok (recommended) to declare all controls as private members of my App class to have a method update their text property (-> an <code>updateLanguage</code> method would do that)</li>
  </ul>