![]() ![]()
|
15
Wizard Creator
Features of JCWizard and JCSplitWizard
Classes
Constructors and Methods
Events
Examples
15.1 Features of JCWizard and JCSplitWizard
JCWizardlets you create and manage a Wizard-style group of dialogs by supplying informative events and special page components with standard buttons. You add aJCWizardListenerto yourJCWizardPages to invoke the actions that each page needs to perform.
Figure 47 : A sample Wizard page.
JCWizardsupplies these features:
- Standard Next, Back, Finish, Cancel and Help buttons that are characteristic of Wizard dialogs.
- You provide instructions for the end-user on each page, and define the actions corresponding to the choices made by the end-user.
- The Wizard's pages are instances of
JCWizardPage. As is usual with Swing components, you do not add children toJCWizardPage. Instead, you call itsgetContentPane()method and add items to it.The
JCWizardcomponent is a container that managesJCWizardPages. The pages are added to it in a way that only one of them shows at a time, but navigation buttons let the end user move back and forth through the deck. The component posts aJCWizardEventas changes occur.
The
JCWizardPageprovides agetContentPane()method to return the panel to which you add content. It automatically builds content to manage the Next, Previous, Finish, Cancel, Help buttons at the bottom right of the page.
JCSplitWizard, on the other hand, creates a split-Wizard layout, which allows for one page to be created with multiple panels, rather than multiple pages with one panel.
Figure 48 : A sample split-Wizard page.
The button features provided for a standard Wizard are also available for the split-Wizard, though there is only one set that will apply to the entire Wizard. (The Back button is automatically unavailable on the first page, and the Next button is automatically unavailable on the last page.) Pages that are added are displayed in the right pane, while the left pane is used for the progress list, if one has been created.
15.2 Classes
The classes in the
JCWizardgroup are:
Creates and manages a Wizard-style set of dialogs. To create your own Wizard, design
JCWizardPages and add Wizard listeners.The event object that carries information about changes to
JCWizardpages.The classes in the
JCSplitWizardgroup are:
Creates a wizard with two panes, and a bottom button panel. The panes can contain any component, or left pane can optionally contain an automatically generated list of Steps.
15.3 Constructors and Methods
JCWizard Constructors
page = new JCWizardPage(JCWizardPage.NEXT |
JCWizardPage's constructor lets you specify the buttons you want on a page by combiningJCWizardPageconstants, as follows:
JCWizardPage.PREVIOUS |
JCWizardPage.FINISH |
JCWizardPage.CANCEL |
JCWizardPage.HELP);JCSplitWizard Constructors
JCSplitWizardhas two constructors. There is a constructor that can be used to create a standard two-pane Wizard, along with buttons and an empty string as a title. The second constructor is equipped with two arguments:
- The
intargument that specifies which buttons should be included;- The
Stringtitle that specifies the title of the progress list.JCWizard Methods
JCWizardinherits both properties and methods fromJPanel. Listed here are the methods thatJCWizarditself defines to provide the needed functionality for managing Wizard pages.
Method
Description
The method takes a parameter (
String name), and moves to the Wizard page with the specified name.JCSplitWizard Methods
Listed here are the methods that
JCSplitWizarditself defines to provide the needed functionality for managing split-Wizard pages.
Method
Description
Accesses the left panel, which can contain an automatically generated list of steps based on titles, an image, help text, or any other desired components.
15.4 Events
A
JCWizardorJCSplitWizardlistens forJCWizardEvents. AJCWizardEventcontains information on theObjectthat triggered the event, theComponent's current page and new page, twoBooleans, whether the event occurred on the last page, and whether the event should be allowed to finish processing.Interface
JCWizardListenermethods are:
15.5 Examples
Please refer to
examples.elements.Wizard.javato see how to construct regular Wizard pages. Briefly, these are the steps:
- Add an instance of a
JCWizardto aJPanelor similar component.- Create a
JCWizardpage.- Specify the buttons that should appear on each page.
- Name the page.
- The content for each page will likely be a
JPanel. Add it to the Wizard page's content pane.- Add the page to the
JCWizard.- Continue adding pages as necessary.
Please refer to
examples.elements.SplitWizard.javato see how to construct split-Wizard pages. Briefly, these are the steps:
- Create an instance of a
JCSplitWizard, adding the desired buttons and determining whether or not a progress list should be generated.
To create a progress list, pass the title of the list as the second argument in the constructor.
If no progress list is desired, simply leave the title null, or use the no-argument constructor.- Create content for the right-hand wizard pages. These can be any instance of
JComponent.- Add the pages to the wizard using
wizard.addPage(JComponent, page title), where page title is the title of the page.- Add the wizard to a container; add listeners, if desired.
- If a progress list has not been specified, call
getLeftPage()to add content to the left pane.
![]() ![]()
|