|
Applet Drawing Shapes
import java.awt.*;
import java.applet.*;
public class Pictures extends Applet
{
public boolean handleEvent(Event e)
{
if (e.id == Event.WINDOW_DESTROY)
System.exit(0);
return(super.handleEvent(e);
}
public void paint(Graphics g)
{
int x[] = (50,89,75};
int y[] = {350,400,450};
Polygon p = new Polygon(x,y,3);
g.drawPolygon(p);
g.drawLine(50,50,100,50); g.drawLine(150,50,150,100);
g:drawLine(200,50,200,10);
g.drawRect(250,50,50,50); g.drawRect(350.,50,100,50);
g.fillRect (500, 50, 50, 50) ;
g.fillRect(600,50,100,50);
g.drawOval (50, 150, 50, 50) ;
g.drawOval(150,150,100,50);
g.drawOval(300,150,50,100);
g. fillOval.( 400, 150, 50, 50 ) ;
g.fill0val(500,150,100,50);
g.fill0val(650,150,50,100);
g.drawArc (50, 250,50,50, 0, 90) ;
g.drawArc(150,250,50,50,45,100);
g.drawArc(250,250,50,50,90,135);
g.drawArc(380,420,50,50,45,100);
g.drawOval ( 350, 350, 100, 100 );
g.drawLine(375,375,377,377);
g.drawLine (425, 375, 427, 377 ) ;
g.drawLine(400; 400, 402, 402) ;
g.fillOval (400, 370, 3, 3) ;
}
}
'****************************************************************
' HTML DOCUMENT
'****************************************************************
<HTML>
<HEAD>
<TITLE> SHAPES </TITLE>
</HEAD>
<BODY>
<APPLET CODE="Drawing.class" WIDTH=600
HEIGHT=600>
</APPLET>
</BODY>
</HTML>
Output
:
This code will display a document containing various shapes.
|