Implementing a Grid Layout Manager with Positionable Components

by Daniel Dee

Layout manager objectifies the component layout strategy. It disentangles component layout code from the drawing code of the container of components. By isolating the implementation of a layout strategy in a separate class, programmer can reuse it by simply assigning an instance of this layout class to the container that requires it. With a layout manager, the layout strategy would have to be embedded within the drawing code of the container itself.

Puzzle Widget

Figure 1: Puzzle, Implemented using the Positionable Grid Layout Manager

This article, published in Volume 3 Issue 12 (December 1998) of the Java Developer's Journal, shows how to write a custom LayoutManager using a fully implemented a grid layout manager with independently positionable components.

Source code associated with this article has been obsoleted and is no longer supported.