title: Why does setting JDialog or JFrame setVisible(true) toggle my IME setting?
body: <p>I found that when I show a <code>JDialog</code> or a new <code>JFrame</code> in my Java swing application will toggle my Chinese Input Method from half-byte mode to full-byte mode in Windows 7.</p>
  
  <p>Why does calling the dialog or frame <code>setVisible(true)</code> method toggle my IME setting?</p>
  
  <p>Does anyone knows what's wrong with the code, or it's a bug of Java?</p>
  
  <p>Procedure to reproduce the problem:</p>
  
  <ol>
  <li>run the application.</li>
  <li>change your Language to one of Chinese Input methods eg. Chinese (Traditional) - Quick</li>
  <li>click the button in the program</li>
  </ol>
  
  <p>My language setting</p>
  
  <p><img src="https://i.stack.imgur.com/7HWVI.jpg" alt="enter image description here"></p>
  
  <p>I have found a similar question <a href="https://stackoverflow.com/questions/16774709/automatic-toggling-of-character-width-by-windows-7-input-methods-in-java">Automatic toggling of character width by Windows 7 input methods in Java</a></p>
  
  <p>and after adding the default locale, it's still not working</p>
  
  <pre><code>import java.awt.Dimension;
  import java.awt.EventQueue;
  import javax.swing.JDialog;
  import javax.swing.JFrame;
  import javax.swing.JButton;
  import javax.swing.JLabel;
  import java.awt.BorderLayout;
  import java.awt.event.ActionListener;
  import java.awt.event.ActionEvent;
  import java.util.Locale;
  
  public class MainWindow {
  
  private JFrame frame;
  private Locale l;
  
  /**
   * Create the application.
   */
  public MainWindow() {
      initialize();
  }
  
  /**
   * Initialize the contents of the frame.
   */
  private void initialize() {
  
      l = new Locale("zh", "zh_TW");
  
      frame = new JFrame();
      frame.setLocale(l);
      frame.setBounds(100, 100, 450, 300);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      JButton btnNewButton = new JButton("New button");
      btnNewButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
  
              JDialog d = new JDialog(frame, "Run", true);
              d.getContentPane().add(new JLabel("dsad"));
              d.setMinimumSize(new Dimension(150, 100));
              d.setLocationRelativeTo(null);
              d.setLocale(l);
              d.setVisible(true);
  
          }
      });
      frame.getContentPane().add(btnNewButton, BorderLayout.CENTER);
  }
  
  /**
   * Launch the application.
   */
  public static void main(String[] args) {
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              try {
                  MainWindow window = new MainWindow();
                  window.frame.setVisible(true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      });
  }
  
  
  }
  </code></pre>