Java Swing Tutorial - Java Shape.getBounds()








Syntax

Shape.getBounds() has the following syntax.

Rectangle getBounds()

Example

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

import java.awt.Shape;
import java.awt.geom.Rectangle2D;
/* ww  w .j a v  a2s  .  c o m*/
public class Main {
  public static void main(String[] args) throws Exception {
    Shape s = new Rectangle2D.Double(0, 0, 72, 72);
    
    System.out.println(s.getBounds());
  }

}

The code above generates the following result.