title: Animating JDialog
body: <p>I created a <code>JDialog</code> which I want to move and resize. My program draws <code>JDialog</code> on the screen. When the user clicks it, it should stretch to the width of the screen and then gain height. I tried it like this.</p>
  
  <pre><code>for(int i = 150; i &lt;= width; i += 3) {
      dialog.setSize(i, 80);
  
      try {
          Thread.sleep(0, 1);
      } catch(Exception e2) {}
  }
  
  for(int i = 80; i &lt;= 200; i++) {
      dialog.setSize(width, i);
  
      try {
          Thread.sleep(1);
      } catch(Exception e3) {}
  }
  </code></pre>
  
  <p>When the code is executed, it will take a while and then the JDialog will be shown stretched immediately. No expanding is shown. </p>
  
  <p>Well, when the user clicks the dialog again, it will reverse the opening animation and close.</p>
  
  <pre><code>for(int i = 200; i &gt;= 80; i--) {
      newMsg.setSize(width, i);
  
      try {
          Thread.sleep(0, 1);
      } catch(Exception e4) {}
  }   
  
  for(int i = 0; i &gt;= -width; i -= 3) {
      newMsg.setLocation(i, 100);
  
      try {
          Thread.sleep(0, 1);
      } catch(Exception e5) {}
  }
  </code></pre>
  
  <p>This one works correctly. The movement is able to be seen. As far as I understand, these codes are otherwise identical except they are reversed. Why doesn't the opening work as expected but the closing does?</p>