B.J. Black's Utilities

The following are various utility classes that I'm making available under the GNU LGPL.

FormLayout

This class is the result of my frustration with making simple forms in Java Swing. Often times, a developer just needs labelled text fields in sequence, followed by a few buttons. Every layout manager built in Swing has problems with this simple problem:

External libraries (such as the otherwise excellent wares from JGoodies are a good solution, but are trying to be too many things imho (and hence are big).

I wanted a solution that:

The solution is FormLayout available via anonymous subversion at http://schmong.org/source. It's a single-source-file LayoutManager that is an (almost) drop-in replacement for managers such as BoxLayout.

Usage

[...control creation...]
   
// The form panel
JPanel form = new JPanel();
FormLayout layout = new FormLayout(form);
form.setLayout(layout);
form.add("Name", name);
form.add("Address", address);
form.add("City/State/ZIP", csz);
form.add("Interests", interests);
form.add("Special Offers?", spam);
form.add(FormLayout.BUTTONAREA, cancel);
form.add(FormLayout.BUTTONAREA, save);

[...assign to JFrame, etc...]

This particular code yields a layout like this:

Example Layout

Download

.ZIP package: schmong-utils.zip

Anonymous SVN: http://schmong.org/source/schmong-utils

CalendarPopup

Again, a class brought about out of frustration. This is an extremely simple-to-use control that is a combination textbox (for direct data entry) and pop-up calendar. Looks like this:

Example Layout

You use it basically like a JTextArea, and can feed it either Date objects from java.util or java.sql (clever!)

Usage

[...control creation...]

// The form panel
JPanel panel = new JPanel();
panel.add(new JLabel("Pick a date:"));
panel.add(new CalendarPopup(d));

[...assign to JFrame, etc...]
        

See the Javadoc for details.

Download

.ZIP package: schmong-utils.zip

Anonymous SVN: http://schmong.org/source/schmong-utils