October 4, 2012 / IST / Language.

Write a program to draw line from corner to corner in JAVA.

import javax.swing.JPanel;
import java.awt.Graphics;
public class MP4 extends JPanel
{
 public void paintComponent(Graphics g)
 {
  super.paintComponent(g);
  int width=getWidth();
  int height=getHeight();
  for(int i=1;i<=15;i++)
  {
   g.drawLine(0,0,width,0);
   width=width+15;
   height=height+15;
  }
 }
}