Java Swing Tutorial - Java Shape.getBounds2D()








Syntax

Shape.getBounds2D() has the following syntax.

Rectangle2D getBounds2D()

Example

In the following code shows how to use Shape.getBounds2D() method.

import java.awt.Shape;
import java.awt.geom.Rectangle2D;
//from w  ww  . ja v  a2s.  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.getBounds2D());
  }

}

The code above generates the following result.