Rectangle.contains

Overview | Methods | Fields | ThisPackage | All Packages

Rectangle.contains

Retrieves a boolean value that indicates whether this rectangle contains the specified rectangle or points.

Syntax

public boolean contains( Point pt )

public boolean contains( int x, int y )

public boolean contains( Rectangle rect )

Parameters

pt

A Point object that specifies the x and y values to be compared to this rectangle's coordinates.

x

The x-coordinate to be compared to this rectangle's coordinates.

y

The y-coordinate to be compared to this rectangle's coordinates.

rect

A Rectangle object that specifies the rectangle to be compared to this one.

Return Value

Returns true if this rectangle contains the specified coordinates; otherwise, returns false.

Remarks

For the contains method to return true when a Point object is specified as a parameter, the following must be true:  The x and y fields of the pt parameter must be greater than or equal to the x and y fields in the rectangle; the Point object's x member must be less than or equal to the sum of this rectangle's x and width members; and the Point object's y member must be less than or equal to the sum of this rectangle's y and height members.

For the contains method to return true when a Rectangle object is specified as a parameter, the entire rectangle specified by the rect parameter must be contained in this rectangle.