Skip to main content

A library for creating Wizards in Swing

Posted by timboudreau on April 17, 2005 at 1:21 PM PDT

I wrote a prototype replacement for the Wizards API in NetBeans - trying very hard to create something clean and easy to use, especially one which didn't require the user of the API to write any more code than absolutely necessary. It's now a project on java.net and I'd love to get some feedback.

The ideas are pretty simple:

  • A wizard does not alter its environment until finish() is called
  • You create a factory for panels. It supplies a list of String IDs for panels, and things call it saying "give me the panel for ID 'foo'".
  • The UI you write puts data the user enters into a Map (listen on a text field, when it changes, call settings.put ("stuffTheUserEntered", theTextField.getText()) and can enable/disable Next/Finish
  • The settings map is handled for you - if the user backs up, settings from the current pane are cleanly removed (it's really a map that delegates to a list of per-panel maps)
  • The UI is pluggable - it comes with a default one (which still needs polishing and localization) - so if you want a different UI, set of buttons, whatever, you have complete freedom to provide a custom implementation
  • Branching and wizards with indeterminate numbers of steps are supported (basically this is conditionally nesting one Wizard inside another, but the convenience class for this makes it painless)

I'm sure it's not perfect yet, and would love to get some feedback. I tried pretty hard to make the javadoc complete and full of examples. You can find the project at wizard.dev.java.net, with the javadoc available as a zip.

Related Topics >>