Swing Components

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.
go to previous page   go to home page   go to next page

Answer:

JButton

Swing Components

Recall that many Swing classes start with J. Similar AWT classes do not start with J. A frequent error is to forget the J and get the wrong class. Then your program will almost work, but not quite, and finding the problem can be hard. For example, the AWT class Button will not work in place of JButton. Here, as a review, is how the class JButton fits into the Swing hierarchy:

Swing Hierarchy

QUESTION 2:

Is a JButton a kind of container?