This article presents a data model based on a Collection implementation that
can be used with Swing components JList and JComboBox. It also discusses a
method to use these same concepts in constructing the user interface of an
application.
Overview
Java Collections are indispensable for building any application, whether GUI
or non-GUI. And the ArrayList class is a heavyweight in the java.util
package. In a GUI application, the user often must choose items from a list,
which can be presented in a variety of forms (drop down combo, list box,
etc.). For example, the Java Swing components JList and JComboBox each have
list data models - ListModel and ComboBoxListModel, respectively. Both
components will react to changes in these models in keeping with the
Model-View-Controller paradigm. However, neither of these models are based on
a Collection, and therefore lack many... (more)
In this month's article I continue my discussion of a list-based UI framework
that I started last month ("ArrayListModel," [JDJ, Vol. 10, issue 10]). The
primary concept behind this idea is a data model that contains elements that
describe parts of an application's user interface. Through a single model,
various aspects of the user interface can be controlled, manipulated, and
visually synchronized. There is a lot of interesting code that accompanies
this article, so I encourage you to download it and check it out. Let's get
started.
Data Model
Recall from last month's article t... (more)
In this month's article I introduce TableLayout, a robust but easy-to-use
LayoutManager for use in any Java Swing application. It's based very loosely
on the HTML TABLE paradigm, where components are placed in table cells in
row-major order. Vertical and horizontal alignment for the component in a
cell can be specified, and a component (cell) may span rows and columns. I
also present Forms-Panel, a JPanel sub-class that abstracts the underlying
TableLayout.
This article assumes you have some familiarity with the design and use of
LayoutManagers in Swing.
Background
I have been ... (more)
This article presents a Java/Swing component implementation of a feature that
is ubiquitous in nearly all desktop applications, particularly Windows
applications - an area in the lower right portion of a window (Frame) that
can be used to resize the window.
Of course, a window can be re-sized with most desktop managers by dragging
the lower-right edge - the additional component simply serves as a visual
indicator of the resize capability, and also increases the margin of error
for the mouse drag.
Typically this component is placed in a status or message area at the bottom
of a ... (more)