info.aduna.swing.wizard
Class Wizard

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by info.aduna.swing.wizard.Wizard
All Implemented Interfaces:
WizardSheetListener, ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
ExportWizard, SourceWizard

public class Wizard
extends JPanel
implements WizardSheetListener, ActionListener

Wizard is a utility class that offers functionality for defining graphical Wizards.

The panels in a Wizard are instances of WizardSheet. The Wizard is presented with the first WizardSheet, subsequent WizardSheets are retrieved from this WizardSheet. All WizardSheets are immediately put in a JPanel with a CardLayout, so that it does not need to resize when switching WizardSheets.

A Wizard offers four buttons that allow the user to select the previous or next WizardSheet or to cancel or finish the Wizard. Objects can register themselves as WizardListener on a Wizard. They are then notified when the action behind any of these buttons has finished. Alternatively, an object can also register itself directly as ActionListener on any of these buttons, if it is not required that it is triggered after the Wizard's underlying action has finished.

See Also:
WizardSheet, WizardListener, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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()
          Create a new Wizard with initially no WizardSheets.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Dispatches the ActionEvents from the Back, Next, Cancel en Finish buttons to the _back, _next, _cancel en _finish methods and updates the button's states.
 void addWizardListener(WizardListener listener)
          Add a WizardListener to the list of WizardListeners.
 JButton getBackButton()
           
 JButton getCancelButton()
           
 WizardSheet getCurrentSheet()
           
 JButton getNextButton()
           
 WizardSheet getStartSheet()
           
 void removeWizardListener(WizardListener listener)
          Remove a WizardListener from the list of WizardListeners.
 void resetToStartSheet()
          Updates the wizard so that the start sheet is the current WizardSheet again.
 void setStartSheet(WizardSheet startSheet)
          Set the WizardSheet this Wizard should start with.
 void show(WizardSheet sheet, boolean initializeSheet)
          Makes the specified WizardSheet the current sheet.
 void stateChanged(WizardSheet sheet)
          Updates the state of the buttons in this Wizard if the event originates from the current WizardSheet.
protected  void updateButtonState(boolean updateFocus)
          Sets the enabled property of the buttons so that it corresponds with the state of the current WizardSheet.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 

Constructor Detail

Wizard

public Wizard()
Create a new Wizard with initially no WizardSheets.

Method Detail

setStartSheet

public void setStartSheet(WizardSheet startSheet)
Set the WizardSheet this Wizard should start with. This immediately fetches all WizardSheets that may follow from it, in order to determine the preferred size of this Wizard. The supplied WizardSheet is immediately made the current sheet. This method should only be applied on an empty Wizard (i.e. not containing any WizardSheets yet).


resetToStartSheet

public void resetToStartSheet()
Updates the wizard so that the start sheet is the current WizardSheet again. Additionally, all sheets currently on the stack are cleared, so that any memory currently occupied can be released.

It is advisable to invoke this method when a Wizard is kept in memory for subsequent uses, to prevent memory leaks (since all sheets are cleared by this method).

This invocation is only valid when the start sheet has been set already.


getStartSheet

public WizardSheet getStartSheet()

getCurrentSheet

public WizardSheet getCurrentSheet()

getBackButton

public JButton getBackButton()

getNextButton

public JButton getNextButton()

getCancelButton

public JButton getCancelButton()

show

public void show(WizardSheet sheet,
                 boolean initializeSheet)
Makes the specified WizardSheet the current sheet. The WizardSheet is optionally initialized.


updateButtonState

protected void updateButtonState(boolean updateFocus)
Sets the enabled property of the buttons so that it corresponds with the state of the current WizardSheet.


stateChanged

public void stateChanged(WizardSheet sheet)
Updates the state of the buttons in this Wizard if the event originates from the current WizardSheet.

Specified by:
stateChanged in interface WizardSheetListener

actionPerformed

public void actionPerformed(ActionEvent e)
Dispatches the ActionEvents from the Back, Next, Cancel en Finish buttons to the _back, _next, _cancel en _finish methods and updates the button's states.

Specified by:
actionPerformed in interface ActionListener

addWizardListener

public void addWizardListener(WizardListener listener)
Add a WizardListener to the list of WizardListeners. It is not checked whether the WizardListener was already present.


removeWizardListener

public void removeWizardListener(WizardListener listener)
Remove a WizardListener from the list of WizardListeners. Nothing happens when the WizardListener was not registered as such.



Copyright © 1997-2008 Aduna. All Rights Reserved.