CHAPTER 36—Applets

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.

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

CHAPTER 36—Applets

This chapter examines Java applets. An applet usually is used as part of a Web page. The applet is responsible for the graphical components and user interaction in a rectangular section of the Web browser's screen. Applets are typically used for user interaction with the Web page.

Chapter Topics:

  • Extending the JApplet class.
  • The setBackground() method.
  • The paint() method.
  • The Graphics class.
  • Methods of the Graphics class:
    • drawString()
    • setColor()
    • drawOval()
    • drawLine()
  • Compiling and running applets.
  • Web pages and HTML.

These notes discuss the JApplet class that is part of the Swing set of components.

QUESTION 1:

(Thought Question: ) Is an applet a Java application?