There are two example programs provided for TableLayout.

The Example1 program compares TableLayout with GridBagLayout. It uses the code found on the API page for GridBagLayout and then adds code to create the equivalent layout using TableLayout.

I hope the TableLayout version is much easier to understand. It's definitely a lot shorter!

The second program is called TableExplorer. While you are free to examine the code, it is really a tool you run to learn how to use the TableLayout.

If you download the FLib source, you can use Ant to build and run the example programs:

cd TableLayout
ant runExample1
ant runTableExplorer

The Example1 class will display two windows, one created using GridBagLayout and the other using TableLayout. You can resize the windows to verify that the behavior is identical.

When you run the TableExplorer program, it will display a text field at the bottom with the words "Start Here!" and an Add button next to it. You create JButton components by entering the component name (which also becomes its label) and pressing the Add button. Each component added shows up in the list above the text field.

Selecting Window / Show Preview Window from the menu will bring up a window containing the JButtons. You can then set the table attributes and table cell defaults to control the table layout. You can also select a component from the list and set its cell attributes. Your changes should be reflected immediately in the preview window.

You can also display a code window which will show you the code necessary to generate the displayed layout.