Delay a loop in Java for animation effect
java, sleep, slider, vaadin, while-loop
Solution
Take a look at the Animator add-on, it provides nice ways to animate components by using browser's client-side capabilities.
Problem
I know this is a Duplicate question. But, No answers helped me to solve my problem. I'm working on a project in Vaadin. In that I have few layouts (ref this links to understand my layout). When I press a button I need to slide the Components in and out. And, I achieved it successfully. 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. ``` setExpandRatio(component, 1.0f); ``` to ``` setExpandRatio(component, 0f); ``` So that it will slide. And to slow down the sliding, I tried this. ``` float i = 1.0; while(i >= 0) { setExpandRatio(component, i); i = i - 0.1; try { Thread.sleep(1000); } catch(InterruptedException ex) {} } ``` It Just waits for 1 second and slides down the component quickly. I also tried using ``` wait(1000); ``` But, no use. Has anyone solved this problem before?