org.pietschy.wizard
Class Wizard

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.pietschy.wizard.Wizard
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class Wizard
extends javax.swing.JPanel

The wizard class is the main entry point for creating wizards. Typically you will create the wizard with your own WizardModel implementation and then call showInFrame(java.lang.String) or one of the releated methods.

In the simplest case, you would subclass StaticModel and add a number of WizardStep instances.

    StaticModel model = new StaticModel();
    model.add(new MyFirestStep());
    model.add(...);
    ...

    Wizard wizard = new Wizard(model);
    wizard.showInFrame("My Wizard");
 

See Also:
StaticModel, DynamicModel, MultiPathModel, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static int BORDER_WIDTH
           
static int EXIT_ON_CLOSE
          When specified as the defaultExitMode, this causes the wizard to continue displaying the final step after finished has been pressed.
static int EXIT_ON_FINISH
          When specified as the defaultExitMode, this causes the wizard to exit immediately once finish is pressed and WizardStep.applyState() has been invoked.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Wizard(WizardModel model)
          Creates a new Wizard that uses the specified WizardModel.
 
Method Summary
 void addWizardListener(WizardListener l)
          Adds a WizardListener to this wizard.
 void cancel()
          Cancels this wizard.
 void close()
          Closes this wizard.
protected  boolean confirmAbort()
          This method is called when the user cancels the wizard while the #activeStep is busy.
protected  ButtonBar createButtonBar()
          Called by the constructor to create the button bar.
protected  javax.swing.JComponent createTitleComponent()
          Called by the constructor to create the wizards title component.
 javax.swing.Action getCancelAction()
          Returns the action that is bound to the cancel button.
 javax.swing.Action getCloseAction()
          Returns the action that is bound to the close button.
 int getDefaultExitMode()
          Gets the exit mode of the wizard, being either EXIT_ON_FINISH or EXIT_ON_CLOSE
 javax.swing.Action getFinishAction()
          Returns the action that is bound to the showCloseButton button.
 javax.swing.Action getHelpAction()
          Returns the action that is bound to the close button.
 HelpBroker getHelpBroker()
           
 javax.swing.Action getLastAction()
          Returns the action that is bound to the last button.
 WizardModel getModel()
          Gets the models this wizard is using.
 javax.swing.Action getNextAction()
          Returns the action that is bound to the next button.
 javax.swing.Action getPreviousAction()
          Returns the action that is bound to the previous button.
 javax.swing.JComponent getTitleComponent()
          Gets the component being used to render the wizards title.
 boolean isOverviewVisible()
          Checks the visibily of the overview panel that is displayed on the wizards left panel.
 void removeWizardListener(WizardListener l)
          Removes a WizardListener from this wizard.
 void reset()
          Resets the wizard.
 void setDefaultExitMode(int defaultExitMode)
          Set the time when the wizard exits.
 void setHelpBroker(HelpBroker broker)
           
 void setOverviewVisible(boolean overviewVisible)
          Configures the visibily of the overview panel that is displayed on the wizards left panel.
protected  void showCloseButton()
          Marks this wizard as finished.
 void showInDialog(java.lang.String title, java.awt.Component parent, boolean modal)
          Displays the wizard in a new JDialog with the specified title.
 void showInFrame(java.lang.String title)
          Displays the wizard in a new JFrame with the specified title.
 void showInFrame(java.lang.String title, java.awt.Component relativeTo)
          Displays the wizard in a new JFrame with the specified title.
 void showInFrame(java.lang.String title, java.awt.Image windowIcon)
          Displays the wizard in a new JFrame with the specified title.
 void showInFrame(java.lang.String title, java.awt.Image windowIcon, java.awt.Component relativeTo)
          Displays the wizard in a new JFrame with the specified title.
 boolean wasCanceled()
          Checks if the wizard was canceled.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BORDER_WIDTH

protected static final int BORDER_WIDTH
See Also:
Constant Field Values

EXIT_ON_CLOSE

public static final int EXIT_ON_CLOSE
When specified as the defaultExitMode, this causes the wizard to continue displaying the final step after finished has been pressed. The wizard is closed when the user presses the close button. This allows the wizard to display a final confirmation screen.

See Also:
EXIT_ON_FINISH, Constant Field Values

EXIT_ON_FINISH

public static final int EXIT_ON_FINISH
When specified as the defaultExitMode, this causes the wizard to exit immediately once finish is pressed and WizardStep.applyState() has been invoked.

See Also:
EXIT_ON_CLOSE, Constant Field Values
Constructor Detail

Wizard

public Wizard(WizardModel model)
Creates a new Wizard that uses the specified WizardModel.

Parameters:
model - the model that the wizard is to use.
Method Detail

setDefaultExitMode

public void setDefaultExitMode(int defaultExitMode)
Set the time when the wizard exits. The two allowable values are EXIT_ON_FINISH and EXIT_ON_CLOSE.

The default value is EXIT_ON_CLOSE

Parameters:
defaultExitMode - the default exit mode.

getDefaultExitMode

public int getDefaultExitMode()
Gets the exit mode of the wizard, being either EXIT_ON_FINISH or EXIT_ON_CLOSE

Returns:
the default close opertation.

createTitleComponent

protected javax.swing.JComponent createTitleComponent()
Called by the constructor to create the wizards title component. The default component will be an instance of DefaultTitleComponent but subclasses may override to provide a custom implementation. Typically the title component listens to the wizard model and updates its appearance accordingly.

Returns:
the wizards title component.
See Also:
getTitleComponent()

getTitleComponent

public javax.swing.JComponent getTitleComponent()
Gets the component being used to render the wizards title. By default this will be an instance of DefaultTitleComponent. Subclasses can change the default by overriding createTitleComponent().

For example, to activate the gradient background on the default title component you can call.

 ((DefaultTitleComponent) wizard.getTitleComponent()).setGradientBackground(true);
 

Returns:
the wizards title component.

createButtonBar

protected ButtonBar createButtonBar()
Called by the constructor to create the button bar. Subclasses may override to provide a custom ButtonBar implementation.

Returns:
the wizards ButtonBar.

reset

public void reset()
Resets the wizard. This method delegates directly to WizardModel.reset().


getModel

public WizardModel getModel()
Gets the models this wizard is using.

Returns:
the wizard models.

isOverviewVisible

public boolean isOverviewVisible()
Checks the visibily of the overview panel that is displayed on the wizards left panel. The overview panel will only be displayed if this property is true and the current WizardModel implements OverviewProvider.


setOverviewVisible

public void setOverviewVisible(boolean overviewVisible)
Configures the visibily of the overview panel that is displayed on the wizards left panel. This method will only have an effect if the current WizardModel implements OverviewProvider.

Parameters:
overviewVisible - true to display the overview, false otherwise.

setHelpBroker

public void setHelpBroker(HelpBroker broker)

getHelpBroker

public HelpBroker getHelpBroker()

getNextAction

public javax.swing.Action getNextAction()
Returns the action that is bound to the next button.


getPreviousAction

public javax.swing.Action getPreviousAction()
Returns the action that is bound to the previous button.


getLastAction

public javax.swing.Action getLastAction()
Returns the action that is bound to the last button.


getFinishAction

public javax.swing.Action getFinishAction()
Returns the action that is bound to the showCloseButton button.


getCancelAction

public javax.swing.Action getCancelAction()
Returns the action that is bound to the cancel button.


getHelpAction

public javax.swing.Action getHelpAction()
Returns the action that is bound to the close button.


getCloseAction

public javax.swing.Action getCloseAction()
Returns the action that is bound to the close button.


showCloseButton

protected void showCloseButton()
Marks this wizard as finished. This will cause the button bar to only display the close button.


cancel

public void cancel()
Cancels this wizard. This method simply fires the WizardListener.wizardCancelled(org.pietschy.wizard.WizardEvent) event.


wasCanceled

public boolean wasCanceled()
Checks if the wizard was canceled. This method will return false unless the user canceled the wizard.

Returns:
true if the user canceled the wizard, false otherwise.

confirmAbort

protected boolean confirmAbort()
This method is called when the user cancels the wizard while the #activeStep is busy. This method displays a JOptionPane asking if the user wants to abort the wizard.

Returns:
true if the user confirms the abort, false otherwise.

close

public void close()
Closes this wizard. This method simply fires the WizardListener.wizardClosed(org.pietschy.wizard.WizardEvent) event.


addWizardListener

public void addWizardListener(WizardListener l)
Adds a WizardListener to this wizard.

Parameters:
l - the listener to add.

removeWizardListener

public void removeWizardListener(WizardListener l)
Removes a WizardListener from this wizard.

Parameters:
l - the listener to remove.

showInFrame

public void showInFrame(java.lang.String title)
Displays the wizard in a new JFrame with the specified title. The frame will be automatically closed when the wizard is completed or canceled. This method will not block.

Parameters:
title - the title of the frame.
See Also:
addWizardListener(org.pietschy.wizard.WizardListener), removeWizardListener(org.pietschy.wizard.WizardListener)

showInFrame

public void showInFrame(java.lang.String title,
                        java.awt.Image windowIcon)
Displays the wizard in a new JFrame with the specified title. The frame will be automatically closed when the wizard is completed or canceled. This method will not block.

Parameters:
title - the title of the frame.
windowIcon - the icon to use for the frame. This is used to configure Frame.setIconImage(java.awt.Image).
See Also:
addWizardListener(org.pietschy.wizard.WizardListener), removeWizardListener(org.pietschy.wizard.WizardListener)

showInFrame

public void showInFrame(java.lang.String title,
                        java.awt.Component relativeTo)
Displays the wizard in a new JFrame with the specified title. The frame will be automatically closed when the wizard is completed or canceled. This method will not block.

Parameters:
title - the title of the frame.
relativeTo - the new JFrame will be displayed relative to this component. If the component is null, the window will be centered on the desktop as per Window.setLocationRelativeTo(java.awt.Component).
See Also:
addWizardListener(org.pietschy.wizard.WizardListener), removeWizardListener(org.pietschy.wizard.WizardListener)

showInFrame

public void showInFrame(java.lang.String title,
                        java.awt.Image windowIcon,
                        java.awt.Component relativeTo)
Displays the wizard in a new JFrame with the specified title. The frame will be automatically closed when the wizard is completed or canceled. This method will not block.

Parameters:
title - the title of the frame.
windowIcon - the icon to use for the frame. This is used to configure Frame.setIconImage(java.awt.Image).
relativeTo - the new JFrame will be displayed relative to this component. If the component is null, the window will be centered on the desktop as per Window.setLocationRelativeTo(java.awt.Component).
See Also:
addWizardListener(org.pietschy.wizard.WizardListener), removeWizardListener(org.pietschy.wizard.WizardListener)

showInDialog

public void showInDialog(java.lang.String title,
                         java.awt.Component parent,
                         boolean modal)
Displays the wizard in a new JDialog with the specified title. The dialog will be automatically closed when the wizard is completed or canceled. This method will block if the dialog is modal.

Parameters:
title - the dialog title.
parent - the component that will own the dialog.
modal - true to make the dialog modal, false otherwise.
See Also:
addWizardListener(org.pietschy.wizard.WizardListener), removeWizardListener(org.pietschy.wizard.WizardListener)


Copyright © 2004 Andrew Pietsch.