Class Rectangle

Class java.awt.Rectangle

Class Members | This Package | All Packages
java.lang.Object
   |
   +----java.awt.Rectangle

public class Rectangle
extends Object
implements Shape, Serializable

A rectangle specifies an area in a coordinate space that is defined by the rectangle's top-left point (xy) in the coordinate space, its width, and its height.

A rectangle's width and height are public fields. The constructors that allow you to create a rectangle, and the methods that allow you to modify one, do not prevent you from setting a negative value for width or height.

A rectangle whose width or height is negative is considered empty, and all methods defined by the Rectangle class behave accordingly. If the rectangle is empty, then the method isEmpty returns true. No point can be contained by or inside an empty rectangle, however the values of width and height are still valid. An empty rectangle still has a location in the coordinate space, and methods that change its size or location remain valid. The behavior of methods that operate on more than one rectangle is undefined if any of the participating rectangles has a negative width or height. These methods include intersects, intersection, and union.