All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.Rectangle

java.lang.Object
   |
   +----java.awt.Rectangle

public class Rectangle
extends Object
implements Shape, Serializable
A rectangle defined by x, y, width and height.


Variable Index

 o height
The height of the rectangle.
 o width
The width of the rectangle.
 o x
The x coordinate of the rectangle.
 o y
The y coordinate of the rectangle.

Constructor Index

 o Rectangle()
Constructs a new rectangle, initialized to location (0, 0) and size (0, 0).
 o Rectangle(Dimension)
Constructs a rectangle and initializes it to the specified width and height.
 o Rectangle(int, int)
Constructs a rectangle and initializes it with the specified width and height parameters.
 o Rectangle(int, int, int, int)
Constructs and initializes a rectangle with the specified parameters.
 o Rectangle(Point)
Constructs a rectangle and initializes it to the specified point.
 o Rectangle(Point, Dimension)
Constructs a rectangle and initializes it to a specified point and dimension.
 o Rectangle(Rectangle)
Constructs a new rectangle, initialized to match the values of the specificed rectangle.

Method Index

 o add(int, int)
Adds a point to a rectangle.
 o add(Point)
Adds a point to a rectangle.
 o add(Rectangle)
Adds a rectangle to a rectangle.
 o contains(int, int)
Checks whether this rectangle contains the specified point.
 o contains(Point)
Checks whether this rectangle contains the specified point.
 o equals(Object)
Checks whether two rectangles are equal.
 o getBounds()
Returns the bounds of this rectangle.
 o getLocation()
Returns the location of this rectangle.
 o getSize()
Returns the size (width by height) of this rectangle.
 o grow(int, int)
Grows the rectangle horizontally and vertically.
 o hashCode()
Returns the hashcode for this Rectangle.
 o inside(int, int)
Deprecated.
 o intersection(Rectangle)
Computes the intersection of two rectangles.
 o intersects(Rectangle)
Checks if two rectangles intersect.
 o isEmpty()
Determines whether the rectangle is empty.
 o move(int, int)
Deprecated.
 o reshape(int, int, int, int)
Deprecated.
 o resize(int, int)
Deprecated.
 o setBounds(int, int, int, int)
Set the bounds of this rectangle to the specified x, y, width, and height.
 o setBounds(Rectangle)
Set the bounds of this rectangle to match the specified rectangle.
 o setLocation(int, int)
Moves the rectangle to have the specificed location.
 o setLocation(Point)
Moves the rectangle to have the specificed location.
 o setSize(Dimension)
Set the size of this rectangle to match the specified size.
 o setSize(int, int)
Set the size of this rectangle to the specified width and height.
 o toString()
Returns the String representation of this Rectangle's values.
 o translate(int, int)
Translates the rectangle.
 o union(Rectangle)
Computes the union of two rectangles.

Variables

 o x
Properties Public 
   x=int 
The x coordinate of the rectangle.

 o y
Properties Public 
   y=int 
The y coordinate of the rectangle.

 o width
Properties Public 
   width=int 
The width of the rectangle.

 o height
Properties Public 
   height=int 
The height of the rectangle.

Constructors

 o Rectangle
    method Rectangle() public 
Constructs a new rectangle, initialized to location (0, 0) and size (0, 0).

 o Rectangle
    method Rectangle(r=Rectangle) public 
Constructs a new rectangle, initialized to match the values of the specificed rectangle.

Parameters:
r - a rectangle from which to copy initial values
 o Rectangle
    method Rectangle(x=int, -
                     y=int, -
                     width=int, -
                     height=int) public 
Constructs and initializes a rectangle with the specified parameters.

Parameters:
x - the x coordinate
y - the y coordinate
width - the width of the rectangle
height - the height of the rectangle
 o Rectangle
    method Rectangle(width=int, -
                     height=int) public 
Constructs a rectangle and initializes it with the specified width and height parameters.

Parameters:
width - the width of the rectangle
height - the height of the rectangle
 o Rectangle
    method Rectangle(p=Point, -
                     d=Dimension) public 
Constructs a rectangle and initializes it to a specified point and dimension.

Parameters:
p - the point
d - dimension
 o Rectangle
    method Rectangle(p=Point) public 
Constructs a rectangle and initializes it to the specified point.

Parameters:
p - the value of the x and y coordinate
 o Rectangle
    method Rectangle(d=Dimension) public 
Constructs a rectangle and initializes it to the specified width and height.

Parameters:
d - the value of the width and height

Methods

 o getBounds
    method getBounds() returns Rectangle public     
Returns the bounds of this rectangle. This method is included for completeness, to parallel the getBounds method of Component.

 o setBounds
    method setBounds(r=Rectangle)  public     
Set the bounds of this rectangle to match the specified rectangle. This method is included for completeness, to parallel the setBounds method of Component.

Parameters:
d - the new size for the Dimension object
 o setBounds
    method setBounds(x=int, -
                     y=int, -
                     width=int, -
                     height=int)  public     
Set the bounds of this rectangle to the specified x, y, width, and height. This method is included for completeness, to parallel the setBounds method of Component.

Parameters:
width - the new width for the Dimension object
height - the new height for the Dimension object
 o reshape
    method reshape(x=int, -
                   y=int, -
                   width=int, -
                   height=int)  public     
Note: reshape() is deprecated. As of JDK version 1.1, replaced by setBounds(int, int, int, int).

 o getLocation
    method getLocation() returns Point public     
Returns the location of this rectangle. This method is included for completeness, to parallel the getLocation method of Component.

 o setLocation
    method setLocation(p=Point)  public     
Moves the rectangle to have the specificed location. This method is included for completeness, to parallel the setLocation method of Component.

Parameters:
p - the new location for the point
 o setLocation
    method setLocation(x=int, -
                       y=int)  public     
Moves the rectangle to have the specificed location. This method is included for completeness, to parallel the setLocation method of Component.

Parameters:
x - the x coordinate of the new location
y - the y coordinate of the new location
 o move
    method move(x=int, -
                y=int)  public     
Note: move() is deprecated. As of JDK version 1.1, replaced by setLocation(int, int).

 o translate
    method translate(x=int, -
                     y=int)  public     
Translates the rectangle.

 o getSize
    method getSize() returns Dimension public     
Returns the size (width by height) of this rectangle. This method is included for completeness, to parallel the getSize method of Component.

 o setSize
    method setSize(d=Dimension)  public     
Set the size of this rectangle to match the specified size. This method is included for completeness, to parallel the setSize method of Component.

Parameters:
d - the new size for the Dimension object
 o setSize
    method setSize(width=int, -
                   height=int)  public     
Set the size of this rectangle to the specified width and height. This method is included for completeness, to parallel the setSize method of Component.

Parameters:
width - the new width for the Dimension object
height - the new height for the Dimension object
 o resize
    method resize(width=int, -
                  height=int)  public     
Note: resize() is deprecated. As of JDK version 1.1, replaced by setSize(int, int).

 o contains
    method contains(p=Point) returns boolean public     
Checks whether this rectangle contains the specified point.

Parameters:
p - the point (location) to test
 o contains
    method contains(x=int, -
                    y=int) returns boolean public     
Checks whether this rectangle contains the specified point.

Parameters:
x - the x coordinate
y - the y coordinate
 o inside
    method inside(x=int, -
                  y=int) returns boolean public     
Note: inside() is deprecated. As of JDK version 1.1, replaced by contains(int, int).

 o intersects
    method intersects(r=Rectangle) returns boolean public     
Checks if two rectangles intersect.

 o intersection
    method intersection(r=Rectangle) returns Rectangle public     
Computes the intersection of two rectangles.

 o union
    method union(r=Rectangle) returns Rectangle public     
Computes the union of two rectangles.

 o add
    method add(newx=int, -
               newy=int)  public     
Adds a point to a rectangle. This results in the smallest rectangle that contains both the rectangle and the point.

 o add
    method add(pt=Point)  public     
Adds a point to a rectangle. This results in the smallest rectangle that contains both the rectangle and the point.

 o add
    method add(r=Rectangle)  public     
Adds a rectangle to a rectangle. This results in the union of the two rectangles.

 o grow
    method grow(h=int, -
                v=int)  public     
Grows the rectangle horizontally and vertically.

 o isEmpty
    method isEmpty() returns boolean public     
Determines whether the rectangle is empty.

 o hashCode
    method hashCode() returns int public     
Returns the hashcode for this Rectangle.

Overrides:
hashCode in class Object
 o equals
    method equals(obj=Object) returns boolean public     
Checks whether two rectangles are equal.

Overrides:
equals in class Object
 o toString
    method toString() returns String public     
Returns the String representation of this Rectangle's values.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index