Picture of the Relations

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:

Not really.

Picture of the Relations

Perhaps a picture is needed. Clouds represent class definitions, solid rectangles represent objects, and dotted rectangles represent the static part of a class. Look back at the example program as you study the diagram.

picture of the relations
  • ButtonFrame extends the class JFrame.
  • main() is a static member of the ButtonDemo class, not part of any object.
  • main() contains a reference variable frm, which refers to a ButtonFrame object.
  • The ButtonFrame frame and its button are displayed on the screen.
  • Events from the button are sent to the ButtonFrame object.
    • The ButtonFrame object is registered as a listener for Action Events.
    • The ButtonFrame class implements ActionListener.

Don't be discouraged if this is less than perfectly clear! It usually takes some time to get all of these relationships straight. A bit more practice would not hurt, either.

QUESTION 18:

(Thought question: ) Could the static main() method be defined as part of the ButtonFrame class? (So that a separate ButtonDemo class is not needed.)