Pages

Ads 468x60px

Monday 17 December 2012

Applet to display ovals rectangles and lines



20.Write an Applet that displays the content of a file.
Program:
                                       Download link to applet to display ovals and lines
/*<applet code="Lines.class"height=500 width=500>
</applet>*/
import java.awt.*;
import java.applet.Applet;
  class Lines extends Applet
{
public void paint(Graphics g)
{
g.drawLine(10,10,50,50);
g.drawRect(10,60,40,30);
g.fillRect(60,10,30,80);
g.drawRoundRect(10,100,80,50,10,10);
g.drawLine(100,10,230,140);
g.drawLine(100,140,230,10);
g.drawOval(20,20,200,120);
g.setColor(Color.green);
g.fillOval(70,30,100,100);
}
}   

Html code:
<html>
<body>
<applet code="Lines.class"height=500 width=500>
</applet>
</body>
</html>

Run process:-
1- develop the applet code(.java)
2-compile the applet code(.class)
3-write the basic HTML structure format
4-develop the APPLET tag for the applet 
5-insert the APPLET tag in HTML code 
6-run it using appletviewer (appletviewer ______.html) or 
                       double clicking on (.htmlfile) you created.





0 comments:

Post a Comment

 

Sample text

Sample Text

Sample Text