net.sf.fmj.ui.wizard
Class Wizard

java.lang.Object
  extended by java.awt.event.WindowAdapter
      extended by net.sf.fmj.ui.wizard.Wizard
All Implemented Interfaces:
java.awt.event.WindowFocusListener, java.awt.event.WindowListener, java.awt.event.WindowStateListener, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
RTPTransmitWizard, TranscodeWizard

public class Wizard
extends java.awt.event.WindowAdapter
implements java.beans.PropertyChangeListener

Adapted Robert Eckstein's sample at http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/ This class implements a basic wizard dialog, where the programmer can insert one or more Components to act as panels. These panels can be navigated through arbitrarily using the 'Next' or 'Back' buttons, or the dialog itself can be closed using the 'Cancel' button. Note that even though the dialog uses a CardLayout manager, the order of the panels is not linear. Each panel determines at runtime what its next and previous panel will be.


Field Summary
static java.lang.String BACK_BUTTON_ACTION_COMMAND
          The String-based action command for the 'Back' button.
static java.lang.String CANCEL_BUTTON_ACTION_COMMAND
          The String-based action command for the 'Cancel' button.
static int CANCEL_RETURN_CODE
          Indicates that the 'Cancel' button was pressed to close the dialog, or the user pressed the close box in the corner of the window.
static int ERROR_RETURN_CODE
          Indicates that the dialog closed due to an internal error.
static int FINISH_RETURN_CODE
          Indicates that the 'Finish' button was pressed to close the dialog.
static java.lang.String NEXT_BUTTON_ACTION_COMMAND
          The String-based action command for the 'Next' button.
 
Constructor Summary
Wizard(java.awt.Dialog owner)
          This method accepts a java.awt.Dialog object as the javax.swing.JDialog's parent.
Wizard(java.awt.Frame owner)
          This method accepts a java.awt.Frame object as the javax.swing.JDialog's parent.
 
Method Summary
 boolean getBackButtonEnabled()
          Mirrors the WizardModel method of the same name.
 boolean getCancelButtonEnabled()
          Mirrors the WizardModel method of the same name.
 javax.swing.JDialog getDialog()
          Returns an instance of the JDialog that this class created.
 WizardModel getModel()
          Returns the current model of the wizard dialog.
 boolean getNextFinishButtonEnabled()
          Mirrors the WizardModel method of the same name.
 java.awt.Component getOwner()
          Returns the owner of the generated javax.swing.JDialog.
 int getReturnCode()
          Retrieves the last return code set by the dialog.
 java.lang.String getTitle()
          Returns the current title of the generated dialog.
 boolean isModal()
          Returns the modality of the dialog.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Method used to listen for property change events from the model and update the dialog's graphical components as necessary.
 void registerWizardPanel(java.lang.Object id, WizardPanelDescriptor panel)
          Add a Component as a panel for the wizard dialog by registering its WizardPanelDescriptor object.
 void setBackButtonEnabled(boolean newValue)
          Mirrors the WizardModel method of the same name.
 void setCancelButtonEnabled(boolean newValue)
          Mirrors the WizardModel method of the same name.
 void setCurrentPanel(java.lang.Object id)
          Displays the panel identified by the object passed in.
 void setModal(boolean b)
          Sets the modality of the generated javax.swing.JDialog.
 void setNextFinishButtonEnabled(boolean newValue)
          Mirrors the WizardModel method of the same name.
 void setTitle(java.lang.String s)
          Sets the title of the generated javax.swing.JDialog.
 int showModalDialog()
          Convienence method that displays a modal wizard dialog and blocks until the dialog has completed.
 void windowClosing(java.awt.event.WindowEvent e)
          If the user presses the close box on the dialog's window, treat it as a cancel.
 
Methods inherited from class java.awt.event.WindowAdapter
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FINISH_RETURN_CODE

public static final int FINISH_RETURN_CODE
Indicates that the 'Finish' button was pressed to close the dialog.

See Also:
Constant Field Values

CANCEL_RETURN_CODE

public static final int CANCEL_RETURN_CODE
Indicates that the 'Cancel' button was pressed to close the dialog, or the user pressed the close box in the corner of the window.

See Also:
Constant Field Values

ERROR_RETURN_CODE

public static final int ERROR_RETURN_CODE
Indicates that the dialog closed due to an internal error.

See Also:
Constant Field Values

NEXT_BUTTON_ACTION_COMMAND

public static final java.lang.String NEXT_BUTTON_ACTION_COMMAND
The String-based action command for the 'Next' button.

See Also:
Constant Field Values

BACK_BUTTON_ACTION_COMMAND

public static final java.lang.String BACK_BUTTON_ACTION_COMMAND
The String-based action command for the 'Back' button.

See Also:
Constant Field Values

CANCEL_BUTTON_ACTION_COMMAND

public static final java.lang.String CANCEL_BUTTON_ACTION_COMMAND
The String-based action command for the 'Cancel' button.

See Also:
Constant Field Values
Constructor Detail

Wizard

public Wizard(java.awt.Dialog owner)
This method accepts a java.awt.Dialog object as the javax.swing.JDialog's parent.

Parameters:
owner - The java.awt.Dialog object that is the owner of this dialog.

Wizard

public Wizard(java.awt.Frame owner)
This method accepts a java.awt.Frame object as the javax.swing.JDialog's parent.

Parameters:
owner - The java.awt.Frame object that is the owner of the javax.swing.JDialog.
Method Detail

getDialog

public javax.swing.JDialog getDialog()
Returns an instance of the JDialog that this class created. This is useful in the event that you want to change any of the JDialog parameters manually.

Returns:
The JDialog instance that this class created.

getOwner

public java.awt.Component getOwner()
Returns the owner of the generated javax.swing.JDialog.

Returns:
The owner (java.awt.Frame or java.awt.Dialog) of the javax.swing.JDialog generated by this class.

setTitle

public void setTitle(java.lang.String s)
Sets the title of the generated javax.swing.JDialog.

Parameters:
s - The title of the dialog.

getTitle

public java.lang.String getTitle()
Returns the current title of the generated dialog.

Returns:
The String-based title of the generated dialog.

setModal

public void setModal(boolean b)
Sets the modality of the generated javax.swing.JDialog.

Parameters:
b - the modality of the dialog

isModal

public boolean isModal()
Returns the modality of the dialog.

Returns:
A boolean indicating whether or not the generated javax.swing.JDialog is modal.

showModalDialog

public int showModalDialog()
Convienence method that displays a modal wizard dialog and blocks until the dialog has completed.

Returns:
Indicates how the dialog was closed. Compare this value against the RETURN_CODE constants at the beginning of the class.

getModel

public WizardModel getModel()
Returns the current model of the wizard dialog.

Returns:
A WizardModel instance, which serves as the model for the wizard dialog.

registerWizardPanel

public void registerWizardPanel(java.lang.Object id,
                                WizardPanelDescriptor panel)
Add a Component as a panel for the wizard dialog by registering its WizardPanelDescriptor object. Each panel is identified by a unique Object-based identifier (often a String), which can be used by the setCurrentPanel() method to display the panel at runtime.

Parameters:
id - An Object-based identifier used to identify the WizardPanelDescriptor object.
panel - The WizardPanelDescriptor object which contains helpful information about the panel.

setCurrentPanel

public void setCurrentPanel(java.lang.Object id)
Displays the panel identified by the object passed in. This is the same Object-based identified used when registering the panel.

Parameters:
id - The Object-based identifier of the panel to be displayed.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Method used to listen for property change events from the model and update the dialog's graphical components as necessary.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - PropertyChangeEvent passed from the model to signal that one of its properties has changed value.

getReturnCode

public int getReturnCode()
Retrieves the last return code set by the dialog.

Returns:
An integer that identifies how the dialog was closed. See the *_RETURN_CODE constants of this class for possible values.

getBackButtonEnabled

public boolean getBackButtonEnabled()
Mirrors the WizardModel method of the same name.

Returns:
A boolean indicating if the button is enabled.

setBackButtonEnabled

public void setBackButtonEnabled(boolean newValue)
Mirrors the WizardModel method of the same name.

Parameters:
newValue - The new enabled status of the button.

getNextFinishButtonEnabled

public boolean getNextFinishButtonEnabled()
Mirrors the WizardModel method of the same name.

Returns:
A boolean indicating if the button is enabled.

setNextFinishButtonEnabled

public void setNextFinishButtonEnabled(boolean newValue)
Mirrors the WizardModel method of the same name.

Parameters:
newValue - The new enabled status of the button.

getCancelButtonEnabled

public boolean getCancelButtonEnabled()
Mirrors the WizardModel method of the same name.

Returns:
A boolean indicating if the button is enabled.

setCancelButtonEnabled

public void setCancelButtonEnabled(boolean newValue)
Mirrors the WizardModel method of the same name.

Parameters:
newValue - The new enabled status of the button.

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
If the user presses the close box on the dialog's window, treat it as a cancel.

Specified by:
windowClosing in interface java.awt.event.WindowListener
Overrides:
windowClosing in class java.awt.event.WindowAdapter
Parameters:
e - The event passed in from AWT.