File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Move an image across a screen ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Move an image across a screen ?" Watch "Move an image across a screen ?" New topic
Author

Move an image across a screen ?

Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hello I am building an Application..NOT an APPLET... and I need to know how to move a Gif File from one point to another. Lets say I want to move teh gif file from point (10,10) on the JPanel to point (50, 90). The image must move in a smooth motion between those points. How do I perfrom this animation?
any one have any code?
Thanks


yours respectfully<br />Avin Sinanan
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi Avin,
This type of animation is usually done by painting the image in different positions accross the screen between the two points. Generally a for loop with a Thread.sleep( x milis ) will do the trick.
Be aware however that if you don't put this painting into a background thread your application will be "frozen" to user input while the painting takes place.
I suggest you search on the Sun site for "SwingWorker" and you'll find a nice little implementation for Swing applications.
Hope that helps,


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
 
Don't get me started about those stupid light bulbs.
 
subject: Move an image across a screen ?