CHAPTER 36—Applets



created: 03/07/98; revised: 07/15/02, 08/18/03

CHAPTER 36—Applets

This chapter examines Java applets.
The methods of an applet are called by another program,
usually a Web browser.
The applet is responsible for the graphical components
and user interaction in a rectangular section of the Web
browser’s screen.
Applets run on the same computer as the Web browser
and are typically used so that the user can interact
with the Web page.

Chapter Topics:

  • Extending the Applet class.
  • Graphics Objects.
  • The drawString() Method.
  • The setBackground() and setColor() methods.
  • Compiling and running applets.
  • Web pages and HTML.
  • The paint() method.
  • The drawOval() method.
  • The drawRect() method.
  • The drawLine() method.
  • Pen colors.

These notes discuss the
Applet class that is part of
the AWT
(Application Windowing Toolkit).
A newer class, JApplet,
is part of the Swing set of components.
However, as of this writing,
JApplet is not commonly used,
and so will not be discussed.
(See chapters 55 through 64 for a discussion of Swing).

QUESTION 1:


(Thought Question: )
All of the applications that
you have seen so far
have a main method.
Do you expect that applets have a main method?