title: Delay a loop in Java for animation effect
body: <p>I know this is a Duplicate question. But, No answers helped me to solve my problem.
  I'm working on a project in <a href="https://vaadin.com/" rel="nofollow noreferrer">Vaadin</a>. In that I have few layouts (<a href="https://stackoverflow.com/questions/15335159/vaadin-expand-components-in-grid-layout-in-vaadin">ref this links to understand my layout</a>). When I press a button I need to slide the Components in and out. And, I achieved it successfully. </p>
  
  <p>But, My problem is; to make it feel better, I want to slow down the sliding effect. So, It will look like an animation kind of stuff. I'm sliding the Components by changing the setExpandRatio() from 1 to 0.</p>
  
  <pre><code>setExpandRatio(component, 1.0f);
  </code></pre>
  
  <p>to</p>
  
  <pre><code>setExpandRatio(component, 0f);
  </code></pre>
  
  <p>So that it will slide.</p>
  
  <p>And to slow down the sliding, I tried this.</p>
  
  <pre><code>float i = 1.0;
  while(i &gt;= 0)
  {
    setExpandRatio(component, i);
    i = i - 0.1;
    try {
      Thread.sleep(1000);
        } 
      catch(InterruptedException ex) {}
  }
  </code></pre>
  
  <p>It Just waits for 1 second and slides down the component quickly. I also tried using</p>
  
  <pre><code>wait(1000);
  </code></pre>
  
  <p>But, no use. 
  Has anyone solved this problem before?</p>