CHAPTER 38 — More Applet Examples

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/15/98; revised: 08/18/03, 02/12/06

CHAPTER 38 — More Applet Examples

This chapter continues the example of the previous chapter.

Chapter Topics:

  • Designing a Circle class
  • Constructors of the class
  • The drawing method
  • Data Access methods
  • Drawing random circles

The paint() method in the applet at the end of the last chapter is too complicated. This is sometimes a sign that a new class is needed to manage the complication. This chapter designs a Circle class to contain the complications of drawing circles.

QUESTION 1:

What data should be part of a Circle object? What methods should it have?