• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Smriti Anchu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know about the method intersects() in the Rectangle class?

Kaydell
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!