The Program Explained
Here is the program again:
import java.awt.*; // import the abstract windowing toolkit
public class ezGUI1
{
public static void main ( String[] args ) // usual start of an application
{
Frame frm = new Frame(); // construct a Frame object
frm.setSize( 150, 100 ); // set it to 150 pixels wide by 100 high
frm.setVisible( true ); // ask it to become visible on the screen
}
}
|
The Frame-object created by new Frame() is a section of main storage in your
computer. It contains lots of information about what should appear on the monitor.
But nothing will appear on the monitor without some additional work.
- The AWT is imported since that is where Frame is defined.
- A Frame object is constructed.
- A section of main memory is used for this object.
- The object contains information about what should be displayed on the monitor,
and how the object should behave.
- The graphics methods of the operating system are set up for the Frame
(but nothing is displayed, yet).
- The reference variable frm refers to the Frame object.
- The object's setSize() method sets its size.
- Instance variables of the object (in main memory) are altered.
- The object's setVisible() method makes it appear on the screen.
|