Java Swing Tutorial - Java Shape.intersects(double x, double y, double w, double h)








Syntax

Shape.intersects(double x, double y, double w, double h) has the following syntax.

boolean intersects(double x,   double y,   double w,   double h)

Example

In the following code shows how to use Shape.intersects(double x, double y, double w, double h) method.

import java.awt.Shape;
import java.awt.geom.Rectangle2D;
/*from  w  w  w. ja  v  a 2 s .com*/
public class Main {
  public static void main(String[] args) throws Exception {
    Shape s = new Rectangle2D.Double(0, 0, 72, 72);
    
    System.out.println(s.intersects(10,10,20,20));
  }

}

The code above generates the following result.