Hi Patrick, This is a function that would return the area of a Polygon whose vertices are given as the first parameter and the no. of sides is given as the second parameter.
------------- Amit [This message has been edited by Amit Agarwal (edited July 01, 2001).]
Joined: Jun 15, 2001
Amit, Thank you very much. The area function worked perfect! One more question. I have an applet that allows me to draw a polygon and then edit the polygon by 'tugging' on each of the nodes to change the geometry of the polygon. How do I refresh the screen without using paint()? After I move the nodes around, graphics remain on the screen that are not desired. If I minimize the browser window and then maximize it, the screen looks correct, with the old graphics removed. Thanks, Patrick [This message has been edited by Patrick Thorse (edited July 03, 2001).]
Just call repaint() on the panel (or applet) you want to redraw. If you're using the AWT (not Swing) you might want to add a back-buffer to get rid of flickering. Daniel
Joined: May 09, 2001
Patrick, In your paint() add a statement to clear the panel in the beginning and redraw the polygon etc. use g.clearRect(0,0,getWidth(),getHeight()); if you have a background color, set the color and instead of clearRect() use fillRect(). Use double buffering in swing to get flicker free drawing. Amit