JAVA PROGRAM TO DRAW LINE,RECTANGLE,ROUNDED RECTANGLE



import java.util.*;
import java.applet.*;
import java.awt.Color;
import java.awt.Graphics;

//<Applet code="Examplegraphics" WIDTH="800" HEIGHT="400"></Applet>

public class Examplegraphics extends Applet{


public void paint(Graphics g){

setBackground(Color.red);

g.setColor(Color.black);
     
        g.drawLine(50,100,50,200);//to draw a box using 4 lines
g.drawLine(50,100,150,100);
g.drawLine(150,100,150,200);
g.drawLine(150,200,50,200);

     
  g.setColor(Color.green);
        g.drawRect(200,50,80,80);// to draw a square


g.setColor(Color.blue);
        g.drawRect(350,50,80,180);// to draw a rectangle
     
     
g.setColor(Color.magenta);
        g.drawRoundRect(250,250,80,80,50,50);// to draw a rounded rectangle
     
}
}


SAMPLE OUTPUT:

No comments:

Post a Comment