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
 public int x
The x coordinate of the rectangle.

 o y
 public int y
The y coordinate of the rectangle.

 o width
 public int width
The width of the rectangle.

 o height
 public int height
The height of the rectangle.

Constructors

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

 o Rectangle
 public Rectangle(Rectangle r)
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
 public Rectangle(int x,
                  int y,
                  int width,
                  int height)
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
 public Rectangle(int width,
                  int height)
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
 public Rectangle(Point p,
                  Dimension d)
Constructs a rectangle and initializes it to a specified point and dimension.

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

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

Parameters:
d - the value of the width and height

Methods

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

 o setBounds
 public void setBounds(Rectangle r)
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
 public void setBounds(int x,
                       int y,
                       int width,
                       int height)
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
 public void reshape(int x,
                     int y,
                     int width,
                     int height)
Note: reshape() is deprecated. As of JDK version 1.1, replaced by setBounds(int, int, int, int).

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

 o setLocation
 public void setLocation(Point p)
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
 public void setLocation(int x,
                         int y)
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
 public void move(int x,
                  int y)
Note: move() is deprecated. As of JDK version 1.1, replaced by setLocation(int, int).

 o translate
 public void translate(int x,
                       int y)
Translates the rectangle.

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

 o setSize
 public void setSize(Dimension d)
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
 public void setSize(int width,
                     int height)
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
 public void resize(int width,
                    int height)
Note: resize() is deprecated. As of JDK version 1.1, replaced by setSize(int, int).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index