Write a program in java to draw the image using the applet.
To execute the applet by appletviewer tool, create an applet that contains applet tag in the comment and compile it. After that run it by appletviewer First.java. Now Html file is not required but it is for testing purpose only.
Program Code:
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet
{
public void paint(Graphics g)
{
g.drawRect(10,10,50,100);
g.drawRect(10,10,50,100);
}
}
/* <applet code="First. class" width="300" height="300"> </applet> */
Output:
To execute the applet by appletviewer tool, write in command prompt:
c:\>javac First.java c:\>appletviewer First.java
Post A Comment:
0 comments: