• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Keeping location of a moving rectangle based on coordinate points?

 
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm reading this right, have a look at the Dragger class in my 2nd reply here:

https://coderanch.com/t/573169/GUI/java/questions-JPanel
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

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




Thanks, will check it out in a few.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic