Hello, 
    I am new to java, and I need help with images. I am trying to move an image up the screen while still allowing another image to move using the arrow keys. If I use 
    `thread.sleep` to move the image, I cant move my other image at the same time. Does anybody have a solution? I am on Mac OSX Lion, if that helps. My code is attached.

Recommended Answers

All 5 Replies

Have you looked at using a Timer? The listener method can change the image's x,y location and call repaint() which will cause the paintComponent() method to be called where the drawImage() method can draw the image at the new x,y location.

But i need the second image to be animated, moving up, while i can still move the first image with the arrow keys.

No problem. You can move many images at the same time. Each image would have its own x,y locations and its own control code that changed its x,y values.

What do you mean by control mode?

BTW Could you please post sample code, because i am new to java and i still dont understand (sorry.)

Don't mind my previous post. I just solved the problem using a timer! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.