I am sick of having to do all of these workarounds for create simple forms using the Swing API. What is the easiest and most effective way to create a simple form ? And whats Layouts should I use. Below is an example of what the form would look like.
etc.. etc.. all aligned. What is the best solution for this type of typical form. Currently I'm trying to utilize the BoxLayout nested but its very difficult to align the labels and the text fields or likewise the text fields etc.. Any help would be greatly appreciated.
The problem with Gridlayout is that is uses up all the room correct? My form is nested within other panels with room to spare at the bottom intentionally for panels in the East of the Border Layout. I've tried to add JPanels with FlowLayout inside the GridLayout but they still take up all avaiable room looking kind of silly.
Originally posted by Steven Bell: I would strongly recommend JGoodies Forms. Makes layouts a breeze, and has a couple of nice features. I really like the seperators (labels on a line, creates a nice visual seperation).
Agree 100% and I am really not an experienced swing developer.
I find designing forms in NetBeans is pretty easy and gives great results. I'm doing more complex layouts so it might not be worth it in your case, as you then have to put up with the netbeans 'do not modify' sections and form files.
Joined: Jan 21, 2003
I appreciate all of the replies so far. This form is actually nested inside a complicated panel which contains several other features but this simple part is giving me trouble. I know that JGoodies forms looks great but I like to know how to do something before I use a GUI tool to do the work that I should know how to do myself. Again thanks for the support and keep em coming.
Joined: Dec 29, 2004
JGoodies forms isn't a GUI tool. It is a package that contains LayoutManagers and a simple, but powerful, means to define growth and size of rows and columns. Here is some layout code I have using JGoodies Forms:
Joined: Jan 21, 2003
I also ran across a LayoutManager caled ParagraphLayout which is the easiest manager I have ever used. You guys might want to also check this out for simple data entry forms. Its a breeze.
I'd recommand using FormLayout in conjunction with a builder. The ones included with the FormLayout package are a good starting point to extend if you need something special. You should be able to get down to just a few add methods.
JGoodies forms comes with a good documentation. I was a bid scary before using it >1 year ago. With the help of the documentation and sample code it was question of 4 hours or so to replace Netbeans generated GridBagLayout with JGoodies FormLayout. Its important that open Source projects do have a good documentation and FormLayout definitivedly has one.