[2322] in java-interest
Re: template .java file for applets
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Fri Sep 29 09:15:11 1995
Date: Wed, 27 Sep 1995 12:35:17 -0800 (PDT)
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Reply-To: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
To: Robert Frost <frost@cdr.stanford.edu>
Cc: java-interest@java.Eng.Sun.COM
Hi Rob,
> Does anyone know of a good generic template java file for creating
> Pre-Beta applets?
Here is a minimal applet that draws a string:
import java.awt.*;
public class HelloWorld extends java.applet.Applet {
public void paint(Graphics g) {
g.drawString("Hello World", 0, size().height*2/3);
}
}
Here is a more elaborate version that produces some debugging output:
import java.awt.*;
public class HelloWorld extends java.applet.Applet {
public void update(Graphics g) {
System.out.println("update()");
super.update(g);
}
public void paint(Graphics g) {
System.out.println("paint()");
g.drawString("Hello World", 0, size().height*2/3);
}
public void init() {
System.out.println("init()");
}
public void start() {
System.out.println("start()");
}
public void stop() {
System.out.println("stop()");
}
public void destroy() {
System.out.println("destroy()");
}
public boolean handleEvent(Event evt) {
System.out.println("Event: " + evt);
return super.handleEvent(evt);
}
}
It would be nice if there were template applets that illustrate
use of audio, double buffering, use of the awt, etc...
Have fun,
Arthur van Hoff
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com