Menu:

14-Mar-2008 Latest component update.

WizardView

component iconJWizardPanel is a wizard panel that accomodates a sequence of pages. The wizard navigates through a number of pages represented by a WizardPage interface. The interface comes with Previous, Next and Finish buttons, while more buttons can be added as required. The JWizardPanel class extends the Swing JPanel component.

component iconJWizardDialog is a wizard dialog that accomodates a JWizardPanel. The JWizardDialog class extends the Swing JDialog component.

title separators
Example wizard panel component

Creation

public JWizardPanel()

public JWizardDialog()
public JWizardDialog(JFrame parent)
public JWizardDialog(JFrame parent, boolean modal)

The default constructors create an empty wizard panel or wizard dialog.

The WizardPage Interface

The provided WizardPage interface represents a page in the wizard and contains the following methods.

public String next();
public String previous();
public String finish();

public JPanel getPanel();
public String getName();

public boolean isFirst();
public boolean isLast();

The next, previous and finish methods give the wizard state and typically indicate the page name to which the wizard should navigate. The methods can also return JWizardPanel.HOLD which indicates that the wizard should remain to the currently displayed page. The last page in the wizard should indicate JWizardPanel.FINISH if the wizard process can complete or otherwise a JWizardPanel.HOLD.

Methods

public void addPage(WizardPage page)

public void setButtonText(int button, String text)
public void setButtonImage(int button, ImageIcon icon)
public void setButtonMnemonic(int button, char c)

public void goToPage(String pageName)
public String getPageName()
public String getState()

public void addControlButton(JButton button, int index)

The provided methods allow you to register pages with the wizard and also customise the provided Previous, Next and Finish buttons. The getPageName() method provides the currently displayed page name, while getState() is either the current page name or JWizardPanel.FINISH to indicate that the Finish button has been pressed.

Events

public void addChangeListener(ChangeListener l)
public void removeChangeListener(ChangeListener l)

Get a notification for a wizard event by adding a ChangeListener to the JWizardPanel or JWizardDialog object. The generated ChangeEvent has the wizard object as the source.