Java Reference
In-Depth Information
public static void main(String[] args)
{
// Create an object of the class GFrame. We can use
// this object to access the methods in GFrame and
// its superclasses
Closeable aframe = new Closeable();
// Use methods in the Component class
// to modify object's default dimensions and screen
// and the setTitle() method of the Frame class to change
// the window title
aframe.setSize(400, 300); // Set frame size
aframe.setLocation(200, 100); // Set frame location
aframe.setTitle(“Closeable Frame Demo”); // Titlebar text
// Display the frame using the show() method of the Window
// class
aframe.show();
}
}
Theresultingwindowoverridesthedefaultsizedefinedinthe
ActiveFrameclass,whichisof300by250pixels.Alsotheprogram'stitle,
asdisplayedinthetitlebar,ischanged.Becausewehaveextended
ActiveFrame,theprogramwindowcanbeclosedbyclickingtheXbutton
on the title bar or by means of the Close command in the system menu.
Figure26-1 isascreensnapshotoftheresultingprogramwindow.
Figure 26-1 Screen Snapshot of the Closeable Program
 
Search WWH ::




Custom Search