Why Write Custom Layout Managers? 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, a programmer can reuse it by simply assigning
an instance of this layout class to the container that requires it. Without a
layout manager the layout code would have to be embedded within drawing code
of the container itself.
Java's AWT supports this concept in the LayoutManager interface and supplies
five implementations that are sufficient in most situations. It's sometimes
more efficient and effective, however, to implement one's own layout manager,
designed specifically for a particular task, rather than struggling with the
standard layout managers.
Let's say we need to draw components on a grid, for example, ... (more)
A Tree for All Occasions
The Java Foundation Class, also known as Swing, in addition to augmenting,
enhancing and generally implementing platform-independent replacements of AWT
components, added the JTree class to its repertoire of new GUI components.
Swing's JTree supports a Windows Explorer-style (outliner-style) tree that
makes it easy to graphically render data with hierarchical relationships. A
limited number of graphical attributes as supplied by the default
look-and-feel provided with Swing - e.g., the icon representing the nodes -
is also readily configurable.
This arti... (more)
What Is a Widget?
A widget is a reusable graphical user-interface (GUI) component that operates
synergistically with callbacks (a mechanism by which a user's action on a
software application's GUI is connected to the code implementing the
application's response to this action. The Implementing Callback article last
month showed how the callback mechanism can be implemented in Java and how
standard AWT components can be extended to support it. Like callback, widget
is a familiar concept to X Toolkit and Motif programmers. This follow-up
article will introduce the reader to the Wid... (more)
What is a Callback?
A callback is a mechanism by which the user's action on a software
application's graphical user interface (GUI) is connected to the code
implementing the application's response to this action. It is a familiar
concept to X Toolkit and Motif programmers. In reality, the actual callback
is the part of the callback mechanism that implements the application
response. In this sense, a callback is also known as a command in
object-oriented circles. This article describes how to implement support for
a Java version of the X Toolkit/Motif-style callback for AWT.
Adva... (more)