A chord is a region bounded by the intersection of an ellipse and a line segment, called a secant. The chord is outlined by using the current pen and filled by using the current brush. The part of the ellipse on one side of the secant is clipped.
To draw a chord, use the Graphics object's drawChord method, which has the following syntax:
drawChord( Rectangle p1, Point p2, point p3 )
The drawChord method's Rectangle parameter designates the area into which the ellipse will be drawn. The two Point parameters identify the points at which the two ends of the secant intersect the ellipse.
The following sample makes two calls to drawChord. The first call draws a chord in the lower-left corner of the display, and the second draws a chord in the upper-right corner. Prior to each call to drawChord, a different brush is associated with the Graphics object to ensure that the two chords, which combine to form a circle, are painted black and white, respectively:
protected void onPaint(PaintEvent e){
Rectangle rcClient = this.getClientRect();
// Associate a black brush with the object and draw a chord.
e.graphics.setBrush(new Brush(new Color(0,0,0)));
e.graphics.drawChord(rcClient, new Point(rcClient.x, rcClient.y),
new Point(rcClient.getRight(), rcClient.getBottom());
// Associate a white brush with the object and draw a chord.
e.graphics.setBrush(new Brush(new Color(255,255,255)));
e.graphics.drawChord(rcClient, new Point(rcClient.getRight(), rcClient.getBottom()), new Point(rcClient.x, rcClient.y));
}