Class java.awt.Rectangle
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.Rectangle

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

public class Rectangle
extends Object
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.
 o Rectangle(int, int, int, int)
Constructs and initializes a rectangle with the specified parameters.
 o Rectangle(int, int)
Constructs a rectangle and initializes it with the specified width and height parameters.
 o Rectangle(Point, Dimension)
Constructs a rectangle and initializes it to a specified point and dimension.
 o Rectangle(Point)
Constructs a rectangle and initializes it to the specified point.
 o Rectangle(Dimension)
Constructs a rectangle and initializes it to the specified width and height.

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 equals(Object)
Checks whether two rectangles are equal.
 o grow(int, int)
Grows the rectangle horizontally and vertically.
 o hashCode()
Returns the hashcode for this Rectangle.
 o inside(int, int)
Checks if the specified point lies inside a rectangle.
 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)
Moves the rectangle.
 o reshape(int, int, int, int)
Reshapes the rectangle.
 o resize(int, int)
Resizes the rectangle.
 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.
 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 reshape
  public void reshape(int x,
                      int y,
                      int width,
                      int height)
Reshapes the rectangle.
 o move
  public void move(int x,
                   int y)
Moves the rectangle.
 o translate
  public void translate(int x,
                        int y)
Translates the rectangle.
 o resize
  public void resize(int width,
                     int height)
Resizes the rectangle.
 o inside
  public boolean inside(int x,
                        int y)
Checks if the specified point lies inside a rectangle.
Parameters:
x - the x coordinate
y - the y coordinate
 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