Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Do you people have a code in Swing such that 2 rectangles doesnt overlap when created

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a Swing application. In one of the UI, through a popup menu, we create a rectangle.. Like this we can create n number of rectangles on the UI.. There is an option to rotate the rectangle.

When i try to rotate the rectangle, the application should not allow one rectangle to overlap with other.

For eg. There is a rectangle whose coordinate points are {(1,1), {2,1), {1,2), (2,2)}.. When i rotate this rectangle its new coordinate points will be {(1,2), (2,3), (1,4), (-1,3)}. Suppose there is already a rectangle in this new position, then it should not allow me to move the present rectangle rather than stay at the same position.

As this very urgent... Need your help in this.. I need a sample code, which solves the above problem

Thanks in advance
Smriti
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you know about the method intersects() in the Rectangle class?

Kaydell
 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic