Java loop delay for animation effect

I know this is a duplicate question. But the answers did not help me solve my problem. I am working on a project at Vaadin . That I have few layouts ( ref this links to understand my layout ). When I click the button, I need to insert and paste components. And I have achieved this successfully.

But, my problem; to make him feel better, I want to slow down the slip effect. So it will look like an animation. I move components by changing setExpandRatio () from 1 to 0.

setExpandRatio(component, 1.0f); 

to

 setExpandRatio(component, 0f); 

So that he glides.

And to slow down the slide, 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 quickly speeds up the component. I also tried using

 wait(1000); 

But it is useless. Has anyone solved this problem before?

+4
source share
1 answer

Take a look at the Animator add-in, it provides nice ways to animate components using the capabilities of the client side of the browser.

+3
source

Source: https://habr.com/ru/post/1469213/


All Articles