Applet is a program to run on the browser and it is embedded on the web page.
This program is not system level
program but it is a network level program. The Applet class is a super class of any applet.
Applet viewer is used to view or test the applet
whether the applet is running properly or not.
In this program we will see how to draw the different types of shapes like line, circle and rectangle. There are different types of methods for the Graphics class of the java.awt.*; package have been used to draw the appropriate shape. Explanation of the methods used in the program is given just ahead :
The drawLine() method has been used in the program to draw the line in the applet. Here is the syntax for the drawLine() method :
drawLine(int X_from_coordinate, int Y_from_coordinate, int X_to_coordinate, int Y_to_coordinate);
The drawSring() method draws the given string as the parameter. Here is the syntax of the drawString() method :
drawString(String string, int X_coordinate, int Y_coordinate);
The drawOval() method draws the circle. Here is the syntax of the drawOval() method :
X_coordinate, int Y_coordinate, int Wdth, int height);
draws the rectangle. Here is the syntax of the drawRect() method
X_coordinate, int Y_coordinate, int Wdth, int height)Here is the java code of the program :.
Here is the HTML code of the program:
<APPLET CODE="CircleLine.class" WIDTH="800" HEIGHT="500"></APPLET>
Recommend the tutorial