File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Best Layout for Simple Forms? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Best Layout for Simple Forms?" Watch "Best Layout for Simple Forms?" New topic
Author

Best Layout for Simple Forms?

Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
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.

Name{Label}: {TextField}
Address:{Label} {TextField}

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.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

GridLayout would work really well for a simple form like that. GridbagLayout is of course the most robust but can be the most complicated. JGoodies Forms would world really well for you to.


GenRocket - A Test Data Generation Platform
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
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.
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
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).
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
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.
William A White
Ranch Hand

Joined: Jul 01, 2004
Posts: 35
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.
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
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.
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
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:
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
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.

JHLabs ParagraphLayout Manager
[ April 07, 2005: Message edited by: Sloan Bowman ]
Scott Delap
author
Ranch Hand

Joined: Apr 05, 2005
Posts: 73
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.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best Layout for Simple Forms?
 
Similar Threads
Here are the dependencies Madhav .
Java GUI Builders?
best solution to questionnaire web app
html file with multiple form elements
How to stop JTextField collapsing when using GridBagLayout?