Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!

# Problem in finding the bounds of rectangle.....

sumukha kris
Greenhorn
Posts: 18
Hello,

How to find the x and y co ordinate of a rectangle in terms of number.
Is there any method .I want it to return the x y co ordinate of that rectangle.
There is getBounds() which returns a rectangle itself but i need in terms of values.
How to do this?

Frank Bacher
Greenhorn
Posts: 19
Have you tried getX() and getY() already?

sumukha kris
Greenhorn
Posts: 18

I tried but it gives the co ordinate position of the mouse click but i need the co ordinates of the drawn rectangle.....
How to do this....

Nathan Pruett
Bartender
Posts: 4121
Rectangle.getX/Y(), not MouseEvent.getX/Y().

"sumukha " -

Welcome to the JavaRanch! We don't have many rules around the ranch, but we do have a policy on displayed names... Please adjust your displayed name to meet the JavaRanch Naming Policy. User names must consist of a first name and a last name.

You can change your user name here.

Thanks! and welcome to the JavaRanch!

Craig Wood
Ranch Hand
Posts: 1535
How to find the x and y co ordinate of a rectangle in terms of number
Look in the Rectangle class api to find what you have to work with.
In the Fields Summary section you have access to the fields "x" and "y".
getX, getY, getLocation and getBounds.
For a given
Rectangle rect = someRectangle
the x part of the location (x, y) of "rect" is accessible with:
int x = rect.x;
double x = rect.getX();
int x = rect.getBounds().x;
int x = rect.getLocation().x;

sumukha kris
Greenhorn
Posts: 18