[prev] [up] [next]

Sorry - this document is unfinished.

Creating a GUI Application

In the previous sections, we have learned how simple classes can be created - now lets create an application, which does something useful with the Person-class objects, we defined there.

In order to make the code simple and easy to understand, we will only create a very simple and easy to understand application: a little person browser application.

The resulting application should be able to read Person objects from a file, add new Persons to that database and finally save the persons back onto the file.

In Smalltalk/X, a framework exists for typicaly applications, which consists of the ApplicationModel, UIBuilder and ValueModel class hierarchies.
In order to make use of this framework, we create our application class as a subclass of ApplicationModel.

Creating a New Application Class

In the browser, select the 'New Application' item from the class-list-menu, and accept the resulting class definition template:

    ApplicationModel subclass:#PersonBrowser
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Applications'

Generating the Initial Application Code

Then, switch the browser to 'class'-protocol, and select the 'generate initial application code' item from the method-category-list-menu.
This generates the basic protocol, which is required by all GUI applications.

After that, you can already start your new application, either by evaluating:

    PersonBrowser open
in a workspace, or by double-clicking on the PersonBrowser class in the browser.

Of course, there is not more than an empty application window - for now.

Modifying the Application's Menu

As a next step, change the application's menu using the menuBuilder:
select the 'menu specs' category in the browser's method-category-list, then double click on the mainMenu selector.
This opens a menuBuilder.
Remove the 'New' and the 'Save' items from the 'File' menu.
When finished, save-back the changed menu either by clicking on the menuBuilders 'Save' button, or by selecting the menuBuilders 'Save' menu-item.
Then close the menuBuilder.

You may want to validate and reopen your application by double clicking on the class again.

Modifying the Application's Window

Now, you should change the layout and appearance of our application, to include a selection-list (to select a person) and a few inputFields (to display and modify a persons data).
To do so, open a windowPainter on the application's windowSpec method (double click on the selector), and drag a selectionInListView (from the galleries lists-section) and a few labels plus inputFields (from the galleries 'text'-section) into the drawing canvas.
Arrange for the selectionList to occupy the top half of the window.

Now, your applications canvas should look like: [GUI1 screen snapshot]

Text to be continued ...

Continue in "Recovering from a Crash".

Copyright © 1996 Claus Gittinger Development & Consulting
Copyright © eXept Software AG

<cg at exept.de>

Doc $Revision: 1.2 $ $Date: 1999/03/22 16:05:47 $