Arcs

An application can draw an ellipse or part of an ellipse by calling the drawArc method. This method draws a curve within the perimeter of an invisible rectangle called a bounding rectangle. The size of the ellipse is specified by two invisible radials extending from the center of the rectangle to the sides of the rectangle.

When calling the drawArc method, an application specifies the coordinates of the bounding rectangle and radials.

The following example draws an arc that fills the client area of a form, and then uses the Graphics object’s drawLine method to draw a line from the top of the arc to its radius, then from its radius to the rightmost side of the ellipse:

protected void onPaint(PaintEvent e){

   Rectangle rcClient = this.getClientRect();

e.graphics.drawArc(rcClient, new Point(rcClient.width /2,rcClient.y), 
   new Point(rcClient.width, rcClient.height / 2));
   e.graphics.drawLine(new Point(rcClient.width / 2, rcClient.y),
      new Point(rcClient.width / 2, rcClient.height / 2));
   e.graphics.drawLine(new Point(rcClient.width, rcClient.height / 2),
      new Point(rcClient.width / 2, rcClient.height / 2));
}