Friday, 14 June 2013
program in java - draw various shapes
import java.awt.*;
class draw extends Frame
{
public static void main(String args[])
{
draw f=new draw();
f.setTitle("My Name");
f.setSize(500,500);
f.setVisible(true);
//f.show();
}
public void paint(Graphics g)
{
int x[]={50,100,50,200};
int y[]={50,150,250,300};
g.drawLine(100,100,300,300);
g.drawOval(300,100,50,100);
g.drawOval(300,100,50,50);
g.drawRect(50,50,100,100);
g.drawRoundRect(200,300,70,70,20,20);
g.drawArc(200,400,30,30,0,180);
g.drawArc(200,400,30,30,0,-180);
g.drawArc(300,410,30,30,0,90);
g.drawArc(300,410,30,30,90,90);
g.drawArc(300,410,30,30,-90,90);
g.drawArc(300,410,30,30,-90,-90);
g.drawPolygon(x,y,4);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment