Manipulating Classes and Objects

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.


Next Stop


Exercises

  1. Create a single Frame object and use the Resize and MoveTo methods to change the windows position and size.

  2. Create two Frame objects that are non-overlapping and use the Resize and/or MoveTo methods to cause them to overlap.

  3. Create two Frame objects and manipulate them so that they have the same shape and are located at the same position. Only one window will be visible. Verify that both windows are still there by moving or resizing one of them to make both visible again.

  4. Make four Frame objects and position them so that each overlaps at least two others.