dcsimg

How can I detect that a Polygon is intersects with a Rectangle?

James Outlaw

If your Polygon Class inherits from java.awt.Shape, you can use the intersects() method to determine if the polygon intersects the rectangle. Something like this:


if (myPolygon.interesects(myRectangle))  {
// do something
}