I’m using Notepad to create my Java source code file. Open up your chosen editor, and type in this code:
//Reference the required Java libraries
import java.applet.Applet;
import java.awt.*;
//The applet code
public class FirstApplet extends Applet {
public void paint(Graphics g) {
//Draw a rectangle width=250, height=100
g.drawRect(0,0,250,100);
//Set the color to blue
g.setColor(Color.blue);
//Write the message to the web page
g.drawString("Look at me, I'm a Java Applet!",10,50);
}
}
Don’t worry too much about what the code means. For your first applet, it’s more important to see how it’s created, compiled and run.


