File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Moving Multiple Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Moving Multiple Objects" Watch "Moving Multiple Objects" New topic
Author

Moving Multiple Objects

Benjamin Jasurda
Greenhorn

Joined: Dec 25, 2003
Posts: 1
Hi:
I'm currently taking my first Java Programming class. My current project involves the creation of 9 reindeer within an applet. Those reindeer have been created. Now I need to be able to move them collectively with a mouseEvent so that they follow the mouse. I can get them to be selected simultaneouslly, but they don't keep their spacing--when I select them with a mouse click, they end up piling up on top of each other.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi,
Welcome to JavaRanch!
Presumably you're getting some x,y coordinates from the mouse event, and drawing the reindeer at those coordinates. What you'll need to do, simply stated, is use different x,y coordinates for each reindeer. You might simply use x+0, x+5, x+10 ... for the 1st, 2nd, 3rd reindeer, or you could do something more complex in which both the x and y coordinates varied for each reindeer, perhaps not even in such a linear way. But anyway, the solution to your problem is quite simple: don't draw them all in the same place!


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Moving Multiple Objects