## how to provide X & Y values for creating polygon? plz refer below

hi to all

Here i have been trying to do a paint application something like there are
2 buttons such as RECTANGLE , ELLIPSE by following those buttons you have some
EMPTY SPACE which enables you to draw these shapes mentioned Above

based on your need you can select a shape either one of these before you draw
so that selected image will be drawn in the EMPTY SPACE but the image appears only after your mouse pointer drawn on the empty space, but not image appeared automatically when the button is selected

So to implement this RECTANGLE ,ELLIPSE i just want these two methods

drawRect(x,y,w,h)

Ellipse2D.Float(x,y,w,h)

for EXAMPLE Consider about RECTANGLE in this methods to find height & width of RECTANGLE i just create 2 variable and by subtracting end point of cursor with the Starting point found height and width of rectangle
this is inside a public void paint method

int width = end.x - start.x; // declaring variables
int height = end.y - start.y; // declaring variables

g.drawRect(start.x, start.y, width, height); // declaring variables to draw RECTANGLE

but now i want to implement POLYGON and the method of this something like
this X & Y points with the N Points

int xpoints[] = {25, 145, 25, 145, 25};
int ypoints[] = {25, 25, 145, 145, 25};
int npoints = 5;

g.drawPolygon(xpoints, ypoints, npoints);

so in this case i exactly don't know How to provide X & Y values based on where the polygon drawn in empty space

and i'm not allowed to draw polygon just by providing X & Y Values(NUMBERS)

Instead of that i need something like getting X & Y values from a EMPTY SPACE and apply those X & Y values instead of numbers

DO I need to use something like X1.y1.x2,y2,x3,y3........x5,y5

i tried for this but not working any help would be much appreciated