If you'd like to download the code for this tutorial you can click here to download it as a tar file. The file contains several files that I'll explain briefly:
Filename | Description |
---|---|
MainController.java |
This includes the main method that gets everything started. Essentially it just constructs the MainFrame and shows it. |
MainFrame.java |
The purpose of this file is to serve as a "dialog launcher". I've scaled this down from a larger project that I'm working on, and in the larger project the buttons on this frame let me launch a variety of dialogs. For the purposes of this tutorial there is just one button though. |
EditProjectPanel.java |
This is the full source code for the class I've shown throughout
this tutorial. The most important part of this class is the
buildProjectEditPanel method. This is the method that builds and
returns the JPanel with the FormLayout. |
ReusableDialog.java |
This is another artifact of my larger project. It is just a JDialog that I was using to add and remove panels from. |
formlayout.jar |
You should download this jar file from
https://forms.dev.java.net/.
They should always have the latest, greatest version. At the time of
this writing the file is named "Forms 1.0.6 ". |
Please note that there are a few artifacts in these files, including extra
methods like jbInit()
, due to the fact that I created this project
with JBuilder. (Yes, I could have cleaned those up ...)
To run the demo just include the FormLayout.jar file in your classpath, compile the files, and run the collection as an application, using the main method in the MainController class to launch it all, like this:
java com.devdaily.formlayout.demo.MainController
The JGoodies FormLayout is both simple and powerful, almost an oxymoron these days. I've just demonstrated the biggest program I've had with the layout: understanding how to get components to resize vertically and horizontally.
I think I can improve on this method slightly by making my vertical-resizing solution a little more specific, but alas, that will have to wait for another tutorial. In the meantime I hope this works as well for you as it has for me.
<<Previous: Fixing the grow and fill resizing problems |