Java-Lines

Lines

The simplest shape we can draw with the Graphics class is a line. The drawLine( ) method takes two pair of coordinates, (x1, y1) and (x2, y2) as arguments and draws a line between them.

Program

2

Program Source 

import java.applet.Applet;
import java.awt.Graphics;

public class Javaapp extends Applet {
 
    public void paint(Graphics g) {
     
        g.drawLine(10,10,100,10);
        g.drawLine(10,10,100,100);
        g.drawLine(100,10,10,100);
        g.drawLine(10,100,100,100);
    }
}

Leave a Comment