:: JGOODIES :: Forms

:: Tips & Tricks ::

Consistency

To design consistently over panels, team members, projects and platforms:
  • Favor factories over builders
  • Favor builders over a pure FormLayout use
  • Favor logical sizes over constant sizes
  • Avoid pixel-sizes
  • Make your layouts stable - use bounded sizes
  • Follow a layout style guide

Good Design Practices

  • Group columns where appropriate
  • Group component rows
  • Balance your design
  • Consider to use symmetry
  • Favor white space over separators
  • Favor separators over TitledBorders
  • Remove visual clutter
  • Reduce your design to its essence
  • Add white space where appropriate
  • Use aesthetic aspect ratios

Good Implementation Practices

  • Favor factories over builders
  • Favor specialized over general builders
  • Favor a panel border over border cols/rows
  • Favor a logical border over constant borders
  • Use a simple grid; extract complex sublayouts
  • Make your layout easy to read:
    • favor string col/row specifications over object specs
    • format your layout specification
    • format your builder code to reflect the layout grid
    • specify columns statically
  • Make simple layouts easy to understand:
    • specify rows statically if there are only a couple of rows
    • favor row numbers over row variables
    • favor static cell constraints over tricky builder cursor commands
    • You should have more components than builder commands
  • Make larger layouts easy to modify:
    • favor row variables over row numbers
    • favor the DefaultFormBuilder over PanelBuilder
  • Favor using and vending JPanels over extending JPanel

Precise Layout

  • Favor non-pixel sizes over pixel-sizes
  • Favor Forms builders over the FormLayout
  • Favor a single layout over nested layouts
  • Group component rows
  • Override a component's min/pref size methods judiciously
  • Avoid to set a component's min/pref (pixel) size
  • Use look&feels that provide a precise micro-design

General Advice on Builders

Write layout code that is easy to understand! Explicit row specifications and cell constraints make your layout easier to understand - but harder to maintain. It is temptive to use the DefaultFormBuilder all the time and to let it add rows automatically. Use a simpler style if it increases the code readability.

If the predefined builders don't fit your needs, write your own!

The given code is meant to assist you, but it should in no way stiffle your creativity. The Forms implementation just reflects the current state of my findings about good design and implementation practices. If you've found something other useful, don't hesitate to extend the Forms. I would appreciate if you send me your extension.

(c) 2003 JGoodies