Rectangle

Name

Rectangle

[Graphic: Figure from the text]

Description

The Rectangle class represents a rectangle by combining its origin (a pair of x and y coordinates) with its size (a width and a height).

Class Definition

public class java.awt.Rectangle extends java.lang.Object implements java.awt.Shape, java.io.Serializable {
 // Variables pubic int height;
public int width;
public int x;
public int y; // Constructors public Rectangle();
public Rectangle (int width, int height);
public Rectangle (int x, int y, int width, int height);
public Rectangle (Dimension d);
public Rectangle (Point p);
public Rectangle (Point p, Dimension d);
public Rectangle (Rectangle r); // Instance Methods public void add (int newX, int newY);
public void add (Point p);
public void add (Rectangle r);
public boolean contains (int x, int y); public boolean contains (Point p); public boolean equals (Object object);
public Rectangle getBounds(); public Point getLocation(); public Dimension getSize(); public void grow (int horizontal, int vertical);
public int hashCode();
public boolean inside (int x, int y); (Deprecated) public Rectangle intersection (Rectangle r);
public boolean intersects (Rectangle r);
public boolean isEmpty();
public void move (int x, int y); (Deprecated) public void reshape (int x, int y, int width, int height); (Deprecated) public void resize (int width, int height); (Deprecated) public void setBounds (Rectangle r); public void setBounds (int x, int y, int width, int height); public void setLocation (int x, int y); public void setLocation (Point p); public void setSize (int width, int height); public void setSize (Dimension d); public String toString();
public void translate (int x, int y);
public Rectangle union (Rectangle r);
}

Variables

height

public int height

The height of the Rectangle.

width

public int width

The width of the Rectangle.

x

public int x

The x coordinate of the Rectangle's upper left corner (its origin).

y

public int y

The y coordinate of the Rectangle's upper left corner (its origin).

Constructors

Rectangle

public Rectangle()

public Rectangle (int width, int height)

public Rectangle (int x, int y, int width, int height)

public Rectangle (Dimension d)

public Rectangle (Point p)

public Rectangle (Point p, Dimension d)

public Rectangle (Rectangle r)

Instance Methods

add

public void add (int newX, int newY)

public void add (Point p)

public void add (Rectangle r)

contains

public boolean contains (int x, int y)

public boolean contains (Point p)

equals

public boolean equals (Object object)

getBounds

public Rectangle getBounds()

getLocation

public Point getLocation()

getSize

public Dimension getSize()

grow

public void grow (int horizontal, int vertical)

hashCode

public int hashCode()

inside

public boolean inside (int x, int y) (Deprecated)

intersection

public Rectangle intersection (Rectangle r)

intersects

public boolean intersects (Rectangle r)

isEmpty

public boolean isEmpty()

move

public void move (int x, int y) (Deprecated)

reshape

public void reshape (int x, int y, int width, int height) (Deprecated)

resize

public void resize (int width, int height) (Deprecated)

setBounds

public void setBounds (Rectangle r)

public void setBounds (int x, int y, int width, int height) [New in 1.1]

setLocation

public void setLocation (int x, int y)

public void setLocation (Point p)

setSize

public void setSize (int width, int height)

public void setSize (Dimension d)

toString

public String toString()

translate

public void translate (int deltax, int deltay)

union

public Rectangle union (Rectangle r)

See Also

Dimension, Object, Point, String