This applet will illustrate the concept of creating multiple objects of a given class and operating on these objects. The Frame class is used in this example. With the applet you will be able to simulate the effect of creating mutliple windows that are displayed on a users screen. A simulate screed is also shown by the large rectangular area below the Frame icon.
The Frame class is depicted by the icon in the upper left-hand portion of the applet. This icon is labelled "FRAME" and has a graphic that looks like a "window", suggesting the use of the Frame class to represent "windows" on a users screen.
An object of the Frame class can be constructed as follows. Begin by clicking on the Frame class. The Frame class will two items: a button labelled "Instantiate" and a menu of constructors. Only one constructor is shown at a time. To change the selected constructor, hold the mouse button down on the control at the right edge of the current constructor selection. To use the selected constructor press the "Instantiate" button. A dialogue box will appear that solicits values for each of the constructor arguments. To complete the construction press the "Instantiate" button on the dialogue window. A "Cancel" button is also provided if you decide not to proceed with the construction of the object. After the "Instantiate" button in the dialogue window is pressed, an icon representing the Frame "object" will be shown and the simulated user's screen will show the corresponding window. The "object" icon shows the "name" constructor parameter and has the same "window" graphic to convey that this object is of the Frame class.
An object can be manipulated as follows. Clicking on the object will cause two items to appear: a button labelled "Exec" and a menu of methods that can be invoked. As with the Frame class icon, only the current method is displayed. To see and select another method hold the mouse button down on the control at the right edge of the current method selection. To execute the current method, press the "Exec" button. A dialgoue box will appear. Parameter values should be given for each parameter after which pressing the "Call" button will perform the selected method. A "Cancel" button is also provided in the dialogue box.
Use the applet to explore the concepts of creating objects of a class and manipulating these objects. A few suggested exercises are given below.
|
Exercises |