/* Drawing a rectangle with a GeneralPath */ import java.awt.*; import java.awt.geom.*; public class RectPath extends java.applet.Applet { public void paint(Graphics g) { Graphics2D g2d = ( Graphics2D ) g; setBackground(Color.white); GeneralPath rect = new GeneralPath ( GeneralPath.WIND_EVEN_ODD ); rect.moveTo( 20.0f, 20.0f ); // ul corner rect.lineTo( 80.0f, 20.0f ); // ur corner rect.lineTo( 80.0f, 80.0f ); // lr corner rect.lineTo( 20.0f, 80.0f ); // ll corner rect.closePath(); // close the rectangle g2d.setColor(Color.green); g2d.fill (rect); } }