Lines

A line is a set of highlighted pixels on a display, identified by two points: a starting point and an ending point. In Windows, the pixel located at the starting point is always included in the line, and the pixel located at the ending point is always excluded (these lines are sometimes called inclusive-exclusive).

An application can draw a single line by calling the Graphics object’s drawLine method. This method takes two Point parameters, which specify the start and end of the line:

protected void onPaint(PaintEvent e){

   Rectangle rcClient = this.getClientRect();

   // Draw lines that divide the screen area equally into four squares.

   e.graphics.drawLine(new Point(rcClient.x, rcClient.height / 2),
                     new Point(rcClient.width, rcClient.height / 2));

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