This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to move images? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to move images?" Watch "How to move images?" New topic

How to move images?

Avin Sinanan
Ranch Hand

Joined: Nov 07, 2001
Posts: 109
Hey does anyone out there know how to move an image across the screen for an application.. The image has to move smotthely between two points. for example the image ha sto move somtthly between (10,10) and (90,60).
Is there anyway tos et how fast it moves between these two points?
Anyone have any code.. teh site is not very helpful.. it only has for applets and am doing applications and the code they give you is so limited... any suggestions or code?

yours respectfully<br />Avin Sinanan
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Try playing with this:
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Originally posted by Avin Sinanan:
The image has to move smoothly between two points.

If you don't like so much flickering, you might want to explore double buffering. Here is Cindy's code with some double buffering for a smoother animation:

Note: You can adjust the timing with the "Thread.sleep(50);" part.
Good Luck,
-Dirk Schreckmann

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: How to move images?
It's not a secret anymore!