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).
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); public Rectangle intersection (Rectangle r); public boolean intersects (Rectangle r); public boolean isEmpty(); public void move (int x, int y); public void reshape (int x, int y, int width, int height); public void resize (int width, int height); 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); }
The height of the Rectangle.
The width of the Rectangle.
The x coordinate of the Rectangle's upper left corner (its origin).
The y coordinate of the Rectangle's upper left corner (its origin).
Constructs an empty Rectangle object with an origin of (0, 0) and dimensions of 0 x 0.
width of Rectangle
height of Rectangle
Constructs a Rectangle object with an origin of (0, 0) and dimensions of width x height.
x coordinate of the Rectangle's origin
y coordinate of the Rectangle's origin
width of Rectangle
height of Rectangle
Constructs a Rectangle object with an origin of (x, y) and dimensions of width x height.
dimensions of Rectangle
Constructs a Rectangle object with an origin of (0, 0) and dimensions of d.width x d.height.
origin of Rectangle
Constructs an empty Rectangle object with an origin of (p.x, p.y) and dimensions of 0 x 0.
origin of Rectangle
dimensions of Rectangle
Constructs a Rectangle object with an origin of (p.x, p.y) and dimensions of d.width x d.height.
original Rectangle
Constructs copy of the given Rectangle.
The x-coordinate of a point to incorporate within the Rectangle.
The y-coordinate of a point to incorporate within the Rectangle.
Extends the Rectangle so that the point (newX, newY) is within it.
The new Point to add to the Rectangle.
Extends the Rectangle so that the point p is within it.
The Rectangle being added to the current Rectangle.
Extends the Rectangle to include the Rectangle r.
The x coordinate to test.
The y coordinate to test.
true if the Rectangle contains the point; false otherwise.
The point to be tested.
true if the Rectangle contains the point; false otherwise.
The object to compare.
true if both Rectangles have the same origin, width, and height; false otherwise.
Object.equals(Object)
Compares two different Rectangle instances for equivalence.
Shape.getBounds()
Bounding Rectangle.
Position of the rectangle.
Gets the current position of this Rectangle.
Dimensions of the rectangle.
Gets width and height of the rectangle.
Amount to extend Rectangle in horizontal direction on both the left and right sides.
Amount to extend Rectangle in vertical direction on both the top and the bottom.
Increases the rectangle's dimensions.
A hashcode to use when using the Rectangle as a key in a Hashtable.
Object.hashCode()
Generates a hashcode for the Rectangle.
The x coordinate to check.
The y coordinate to check.
true if (x, y) falls within the Rectangle, false otherwise.
Checks to see if the point (x, y) is within the Rectangle. Replaced by contains(int, int).
Rectangle to add to the current Rectangle.
A new Rectangle consisting of all points in both the current Rectangle and r.
Generates a new Rectangle that is the intersection of r and the current Rectangle.
Rectangle to check.
true if any points in r are also in the current Rectangle, false otherwise.
Checks to see if r crosses the Rectangle.
true if the Rectangle is empty, false otherwise.
Determines if the rectangle is dimensionless (i.e., width or height are less than or equal to 0).
The new x coordinate of the Rectangle's upper left corner.
The new y coordinate of the Rectangle's upper left corner.
Changes the Rectangle's origin to (x, y). Replaced by setLocation(int, int).
The new x coordinate of the Rectangle's upper left corner.
The new y coordinate of the Rectangle's upper left corner.
The new width.
The new height.
Changes Rectangle's origin and dimensions. Replaced by setBounds(int, int, int, int).
The new width.
The new height.
Changes Rectangle's dimensions. Replaced by setSize(int, int).
A Rectangle describing the new bounds.
Changes Rectangle's location and size.
The new x coordinate of the Rectangle's upper left corner.
The new y coordinate of the Rectangle's upper left corner.
The new width.
The new height.
Changes Rectangle's location and size.
New horizontal position.
New vertical position.
Relocates the rectangle.
New position for component.
Relocates the rectangle.
New width.
New height.
Resizes the rectangle.
New dimensions.
Resizes the rectangle.
A string representation of the Rectangle object.
Object.toString()
Amount to move Rectangle horizontally.
Amount to move Rectangle vertically.
Moves the Rectangle's origin to (x+deltax, y+deltay).
Rectangle to determine union with.
The smallest Rectangle containing both r and the current Rectangle.
Generates a new Rectangle by combining r and the current Rectangle.
Dimension, Object, Point, String
This HTML Help has been published using the chm2web software. |