I did some fooling around with it...while looking here:
http://download.oracle.com/javase/tutorial/deployment/applet/lifeCycle.html
You can't run it with the tool bar arrow. You can run it by pulling down the run tab and choosing 'run file'. You will then see that an html file is created. The applet viewer is called and this program works.
However, when I navigate over to the html file and try to open it, I get just a black box in Firefox. I don't see any error messages, however! But, take a look at the page source and you'll see how to designate locations. Here it is on mine:
package BradenJApplet;
import java.awt.Graphics;
import java.applet.Applet;
public class maincode extends Applet {
StringBuffer buffer;
public void init() {
buffer = new StringBuffer();
addItem("initializing... ");
}
public void start() {
addItem("starting... ");
}
public void stop() {
addItem("stopping... ");
}
public void destroy() {
addItem("preparing for unloading...");
}
private void addItem(String newWord) {
System.out.println(newWord);
buffer.append(newWord);
repaint();
}
public void paint(Graphics g) {
g.drawString("test using Applet & init(), etc", 150, 100);
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0,
getWidth() - 1,
getHeight() - 1);
//Draw the current string inside the rectangle.
g.drawString(buffer.toString(), 25, 15);
}
}
+add
Unca Alby: I'm surprised that you don't know about override. It does exist in Java. A search for "java override" gets a link to the tutorial site:
http://download.oracle.com/javase/tutorial/java/IandI/override.html
When overriding a method, you might want to use the @Override annotation that instructs the compiler that you intend to override a method in the superclass. If, for some reason, the compiler detects that the method does not exist in one of the superclasses, it will generate an error. For more information on @Override, see Annotations.