main()
method?
It is a static
method of
the class TestFrame1
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:
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.
Do you always want to exit the program when the close button (the little X button) is clicked?