Draw Line with java.awt.Graphics - Java 2D Graphics

Java examples for 2D Graphics:Line

Description

Draw Line with java.awt.Graphics

Demo Code


import java.applet.Applet;
import java.awt.Graphics;
 
 
public class Main {
 
        public void paint(Graphics g){
                //this will draw a line between (10,10) and (50,50) coordinates.
                g.drawLine(10,10,50,50);
               /*w w  w .j  av a2s.c o  m*/
                //draw vertical line
                g.drawLine(10,50,10,100);
               
                //draw horizontal line
                g.drawLine(10,10,50,10);
        }
}

Related Tutorials