Suppose that we need to change the position of a Swing item (JCheckBox for example) from the position : (0,0,70,25) to (100,0,70,25).
Usually i do :
... And the Box then is moved to the new position IN ZERO SECONDS.
... But, what if we need it to go to the new position continuously TAKING 1 SECONDE or more ??!
(i.e. we need it to move continuously starting from (0,0,70,25) and arriving to (100,0,70,25) in a trip taking 1 second or more)
Same Question for many other Actions like Changing a Panel Size, Changing a Label Color and so ...
i have a general idea that we have to use something like Threads or others may be !? but i need a very simple example showing how to do that in a very simple and quick code...
Many thanks for any help.
You would use a Swing Timer that moves the component a small bit with each iteration (calling revalidate/repaint after each move) and then which has been set to stop once the component is where you want it. This is no different from other simple Swing animations.
Many thanks ... Do u have a simple code please ?!
There are lots of pieces of sample/simple code on this forum. Use Search here for "Timer"
Cross posted at http://www.javaprogrammingforums.com...sing-time.html