go to previous page   go to home page   go to next page

Answer:


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:

Do you always want to exit the program when the close button (the little X button) is clicked?