@ Separate Programs -Applet to display ovals rectangles and lines
Write an Applet that displays the content of a file.
Program:
1./*<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);
}
}
</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);
}
}
2. Html code:
<html>
<body>
<applet code="Lines.class"height=500 width=500>
</applet>
</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.
No comments:
Post a Comment