[ Previous section | Next section | Table of Contents ]

The Container Control

The DataContainer control is a visual control which contains items. The set of items may be displayed in one of several views. This is very similar in look and function to the Container control in OS/2 and the Tree and List controls in Windows 95. A DataContainer may display itself in a Details view, List view, Tree view or Icon view.

The DataContainer holds a reference to a list of ContainerItems. This list is rendered in the DataContainer window as appropriate to the current view. The DataContainer may have an optional title.


Visual Appearance

In the Icon view, each ContaineItem's associated image and text are drawn to represent the item. An item is not required to have an associated image. The items are drawn in a left-to-right and top-to-bottom arrangement. This is an example (from the SAMPLES.ZIP file) of what an Icon view looks like:

In the List view, each ContainerItem's associated text is drawn to represent the item. The items are drawn in a top-to-bottom arrangement. This is an example (from the SAMPLES.ZIP file) of what a List view looks like:

In the Tree view, each ContainerItem's associated text is drawn to represent the item. The items are drawn in a top-to-bottom arrangement. This view is similar to the List view with the exception that parent/child relationships between ContainerItems can be shown. This is an example (from the SAMPLES.ZIP file) of what a Tree view looks like:

In the Details view, each ContaineItem's column data are drawn to represent the item. The items are drawn in a top-to-bottom arrangement. Column titles and vertical separator lines are optional and column data may be any object. If a column for an item is a java.awt.Image, it will be drawn as one. Otherwise, the object's toString() method will be used to retrieve the string which will represent the column value. This is an example (from the SAMPLES.ZIP file) of what a Details view looks like:


Item Selection

The DataContainer control supports three styles of item selection.

Single
This style allows zero or one item to be selected at a time.
Forced Single
This style forces one and only one item to be selected at all times (unless the container is empty).
Multiple
This style allows zero or more items to be selected at any time.

Any time an item is selected, deselected or double clicked, an appropriate event is posted to the DataContainer's owner.


Required Classes

There are six classes involved with this control (although it is pretty useless without any ContaineItems to display).

DataContainer This class is the container object
HotSpot This class is used by the DataContainer class to manage its list of mouse hot spots. It may be used in the same manner for any custom control which has multiple mouse hot spots.
IconCanvas This class performs all the graphics rendering for the Icon view.
ListCanvas This class performs all the graphics rendering for the List view.
TreeCanvas This class performs all the graphics rendering for the Tree view.
DetailsCanvas This class performs all the graphics rendering for each pane in the Details view.


[ Previous section | Next section | Table of Contents ]