• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best Layout for Simple Forms?

 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic