This section illustrates you how to implement the wizard.
In SWT, the class WizardDialog shows a wizard to the user. In the given example, we have add four pages to the Wizard i.e. NamePage, QuestionPage, MoreInformationPage and ThanksPage by using the method addPage(). The method performFinish() defined by the class Wizard implement finish processing for the wizard. The class WizardPage implements the wizard pages. In the NamePage, we have create a form including two fields name and email. If the user enter the fields ,he can move to the next page, i.e QuestionPage. In this page, we have asked a question whether he want to ask any question. For selection, we have create two radio buttons Yes or No. If the user clicks yes button, then only he will move to the MoreInformationPage, otherwise he will move to the Thanks page. In the MoreInformationPage, we have create a text box to ask the question.
The method setDefaultPageImageDescriptor() of class Wizard sets the image descriptor for the wizard. The class ImageDescriptor allows to create a SWT image. The method createFromFile() creates and returns a new image descriptor from a file.
The method setPageComplete() of Boolean type sets whether this page is complete or not. The method getNextPage() of class IWizardPage returns the wizard page that would have to be shown if the user press the Next button.
Here is the code of WizardExample.java
Output will be displayed as:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Demonstrates Wizard
Post your Comment