aspose file tools*
The moose likes Java in General and the fly likes Keeping location of a moving rectangle based on coordinate points? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Keeping location of a moving rectangle based on coordinate points?" Watch "Keeping location of a moving rectangle based on coordinate points?" New topic
Author

Keeping location of a moving rectangle based on coordinate points?

Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Okay so I have a set of rectangles that I need to be able to move.





Basically at this point once it gets the x,y values that are inside the rectangle it will move the coordinates of the Rectangle's x,y to where I'm moving it, so my mouse position is always 0,0. What I want is to be able to have the rectangle move based on it's exact position clicked i.e, if I click 20,20 inside the rectangle I want to always be at 20,20.

So what exactly I'm looking for is if there is a method or something that I know where exactly inside the rectangle I am and the distance from that point to the outside to recreate my rectangle. so if I am at 20,20 in a 100,100 rectangle, then I should know I'm 20 from the xtop, ytop and 80 from xbot,ybot.

Thanks,

~JO
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
If I'm reading this right, have a look at the Dragger class in my 2nd reply here:

http://www.coderanch.com/t/573169/GUI/java/questions-JPanel
Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Michael Dunn wrote:If I'm reading this right, have a look at the Dragger class in my 2nd reply here:

http://www.coderanch.com/t/573169/GUI/java/questions-JPanel



Thanks, will check it out in a few.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Keeping location of a moving rectangle based on coordinate points?