Basic HTML version of Foils prepared June 5 99

Foil 35 The Simplest Java Applet: Hello, World!

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


1 Java applets are part of the class hierarchy that can call methods to display on a screen (within the browser window). One way to draw on the screen is to call the method drawString from the standard method paint.
2 import java.awt.Graphics;
3 public class HelloApplet extends java.applet.Applet
4 { public void paint (Graphics g)
5 { g.drawString("Hello World!", 5, 25);
6 }
7 }
8 The import statement allows the use of methods from the Graphics class without the dot notation .
9 The paint method displays a graphics object on the screen - one of the standard methods that takes the place of main for applets.
10 Puts this as a subclass of Applet.

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Jun 5 1999