void drawString(String message,intx,inty) here message is the string output in java the upper right corner is location 0,0 .Pro Java Tricks is displayed at the position 200,200
KEY POINTS ON APPLET:
- Applet do not need main class.
- Applet must be read under appletviewer OR a Java-compatible browser.
- Applet use interface provided by awt.
STEPS FOR CREATING AND RUNNING APPLET:
Following are the three simple steps to create and run applet in command promptSTEP #1:
paste this code in notepad file and save file name as firstapp.html choose the file type as all type and sve in it in the bin folder
<html> <body>
<applet code="firstapp" width="300" height="300">
</applet>
</body>
</html>
STEP# 2:
paste the below code in notepad file and save file name as firstapp.java choose the file type as all type
import java.awt.*;
public class firstapp extends Applet
{
public void paint(Graphics g){
g.drawString("Pro Java Tricks",200,200);
}
}
NOTE:
That class name and name in the html code should be same.
STEP #3:
compile the code by following command
name of drive:\jdk\bin>javac firstapp.java
0 comments:
Post a Comment