There is ways to draw basic shapes like circles, ovals, lines, arcs, squares, rectangles, rounded rectangles, and pol Ygons. Specific drawing methods like Graphics.drawOval()
. This example uses these methods. The second is to construct a shape and then use to Graphics2D.draw()
draw the shape. See the package for java.awt.geom
examples that create shapes.
Seee575The quintessential Drawing program public void Paint (Graphics g) {graphics2d g2d = (graphics2d) g; G2d.drawline (X1,Y1,X2,y2); G2d.drawoval (x,y,W,h); G2d.drawrect (x,y,W,h); A start angle of 0 represents a 3 O ' clock position, represents a, O ' clock position,//and-90 (OR) rep Resents a 6 o ' clock position int startangle = $; int arcangle =-60; G2d.drawarc (x,y,W,h, StartAngle, Arcangle); G2d.drawroundrect (x,y,W,h,Arcwidth,Archeight); Polygon Polygon = new Polygon (); Polygon.addpoint (x,y); ADD More points ... g2d.drawpolygon (polygon); }
e586. Drawing Simple Shapes