[]
This class stores the x-coordinate, y-coordinate, width, and height of a rectangle. Use it to describe rectangular areas when working with layout, drawing, or positioning APIs.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
double x = rectangle.getX();
double y = rectangle.getY();
double width = rectangle.getWidth();
double height = rectangle.getHeight();
Rectangle(double x,
double y,
double width,
double height) final doublefinal doublegetWidth()final doublegetX()final doublegetY()final voidsetHeight(double value) final voidsetWidth(double value) final voidsetX(double value) final voidsetY(double value) Initializes the rectangle using the x-coordinate and y-coordinate of its upper-left corner, together with the specified width and height.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
x - The x-coordinate of the upper-left corner of the rectangle.y - The y-coordinate of the upper-left corner of the rectangle.width - The width of the rectangle.height - The height of the rectangle.Use this method to retrieve the rectangle's horizontal position without changing its size.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
double x = rectangle.getX();
Use this method to update the rectangle's horizontal position without changing its size.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
rectangle.setX(40.0);
value - The x-coordinate of the upper-left corner of the rectangle.Use this method to retrieve the rectangle's vertical position without changing its size.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
double y = rectangle.getY();
Use this method to update the rectangle's vertical position without changing its size.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
rectangle.setY(40.0);
value - The y-coordinate of the upper-left corner of the rectangle.Use this method to retrieve the rectangle's horizontal size without changing its x-coordinate, y-coordinate, or height.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
double width = rectangle.getWidth();
Use this method to update the rectangle's horizontal size without changing its x-coordinate, y-coordinate, or height.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
rectangle.setWidth(160.0);
value - The width of the rectangle.Returns the height value specified when the rectangle is created or last updated by setHeight(double).
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
double height = rectangle.getHeight();
Use this method to update the rectangle's height without changing its x-coordinate, y-coordinate, or width.
Rectangle rectangle = new Rectangle(10, 20, 120, 80);
rectangle.setHeight(100.0);
value - The height of this rectangle.