Picture of the Frame

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:

  • How many objects are there? One
  • Where is the main() method? It is a static method of the class TestFrame1

Picture of the Frame

The TestFrame1 class is defined so that there is a place for the main() method. Because main() is a static method, it is not part of any object. Static methods can execute without being part of an object. Review the first chapter on objects (chapter 25) if this is unclear. Here is a picture of what is going on:

picture of the frame

When the main() method executes, it asks the system to create a JFrame object (with new). The variable frame refers to that object, so the object's methods can be called.

The Java system keeps the frame active, even after the main() method has ended. The user can click on the frame, drag it on the monitor, resize it, and do all the usual things.

QUESTION 6:

If you change frame.setSize(150, 100)
to frame.setSize(300, 100) how will the frame appear?