Creating Your Own Classes

Tom Kelliher, CS 116

Sept. 18, 2002



Lab 3 write-up, source code, and postlab due Friday, beginning of class.

Quiz at beginning of class.


Re-read Ch. 4, prepare for Friday's lab (look over on web site).

From Last Time

Finished-up Lab 3.


  1. Creating your own classes.

  2. Layout managers.

Coming Up

Lab 4.

Creating Your Own Classes

The class constructor is of the same name as the class. The arguments to the constructor should be the properties which differ for objects in the class. You declare the types of the arguments in the constructor definition:

ClassName ( argType argName, ...  )
   ...  // initialize an object of this class type.  
       // This is executed once when the object is created
User defined classes are used exactly the same way as any other class.

Layout Managers

  1. You may specify the ``layout'' of widgets in a container by setting up a ``Layout Manager''. You use the setLayout() method for containers to do this.

  2. The default is ``Flow Layout''. Other layouts are ``Border Layout'' and ``Grid Layout''.


Thomas P. Kelliher
Mon Sep 16 09:31:30 EDT 2002
Tom Kelliher