//FirstApplet.java import javax.swing.*; //for JApplet and other J... classes import java.awt.*; //for Graphics drawing //an applet adds to (extends) the JApplet class public class FirstApplet extends JApplet { //note there is no ...main.. in an applet (it's not an application) //paint method draws in the applet area. public void paint (Graphics g) { //the draw methods draw in the applet area. //the coordinate system's origin is in the upper left corner. //x gets larger going to the right //y gets larger going down the screen g.drawLine(5, 5, 400, 400); //startx, starty, endx, endy g.drawRect(100, 100, 50, 30); //x,y of upper lefthand corner, width, height g.drawOval(50, 50, 40, 80); //x,y of upper lefthand corner of bounding box, width, height g.drawString("Hi there!",200,200); //string to display, x,y of left bottom } } /* applets do not run by themselves. they run as part of a web browser or the appletviewer. To run an applet, an .html file is needed that contains the HTML applet tag whose code attribute is the name of the .class file: The html file can be any name but for organizational purposes we'll use the same name as the applet. Compile the Java source file and then execute the .html in JCreator to test it. The appletviewer will run. The applet can also be run in a web browser by opening the .html file. Summary: FirstApplet.java ---- compiled ---> FirstApplet.class FirstApplet.html has the above two lines. Have all three files in the same folder. [Norton irritation: antivirus software can be configured to disallow running of applets, so check/change your home computer's Norton settings to allow running applets.] */