|
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||
See:
Description
| Interface Summary | |
|---|---|
| DataLookup | Provides a simple interface for a data lookup mechanism used by DataModel. |
| Step | Models a simple step in a sequence of steps. |
| StepDescriptionRenderer | Provides an interface for rendering step meta information. |
| StepListRenderer | Provides an interface for rendering step sequence meta information. |
| StepModelCustomizer | Enables dynamic step sequences. |
| WizardModel | Models a sequence of steps. |
| WizardModelListener | Provides an interface for wizard model event listeners. |
| Class Summary | |
|---|---|
| AbstractStep | Provides a basic Step implementation. |
| DataModel | Provides a data container that can be shared by steps aiming to collect data. |
| DefaultDataLookup | Default implementation for DataLookup using reflection. |
| DefaultWizardModel | Default implementation for WizardModel. |
| DefaultWizardModel.DummyStep | Step implementation used in dynamic wizard models. |
| JavaHelpSupport | Provides for a seamless integration of jwizz with JavaHelp. |
| Wizard | The main component class. |
| WizardBeanInfo | |
| WizardContentPane | The wizard's content pane. |
| WizardModelEvent | Information transport object for event notification. |
Main package. In order to create a new wizard you need to instanciate class Wizard passing an appropriate step model. Furthermore you will want to attach a listener to the wizard model in order to get notified when the wizard is either canceled or completed:
//create wizard model
WizardModel model = new DefaultWizardModel(new Step[]{
//populate wizard model with custom steps
new StartStep(),
new DataInputStep(),
new FinishStep()
});
//add listener to wizard model
model.addWizardModelListener(...);
//instanciate wizard
Wizard wizard = new Wizard(model, "My Wizard");
//show wizard
wizard.pack();
wizard.setVisible(true);
In order to collect user input data throughout the steps, you should use DataModel and DataLookup:
//create wizard model
DataModel data = new DataModel();
WizardModel model = new DefaultWizardModel(new Step[]{
//populate wizard model with custom steps
new StartStep(),
new DataInputStep1(data),
new DataInputStep2(data),
new FinishStep()
});
//add listener to wizard model
model.addWizardModelListener(new Evaluator(data));
...
class DataInputStep1 extends AbstractStep {
protected DataModel data;
public DataInputStep1(DataModel data) {
super("Data Input 1", "Put in data here.");
this.data = data;
}
protected JComponent createComponent() {
JComponent stepComponent = ...;
//register data input source with data model
return stepComponent;
}
...
}
class Evaluator implements WizardModelListener {
protected DataModel data;
public Evaluator(DataModel data) {
this.data = data;
}
public void wizardFinished(WizardModelEvent e) {
//evaluate user input data and take action here
}
public void wizardCanceled(WizardModelEvent e) {}
public void stepShown(WizardModelEvent e) {}
public void wizardModelChanged(WizardModelEvent e) {}
}
Registering a data input source with a data model is fairly easy:
//input source
JTextField inputField = new JTextField();
//obtaining data lookup mechanism
Method method;
try {
method = inputField.getClass().getMethod("getText", null);
} catch (NoSuchMethodException nsme) {} //does not occur
DataLookup lookup = new DefaultDataLookup(inputField, method, null);
//register lookup mechanism with data model
data.registerDataLookup("myKey", lookup);
Looking up data from registered data input sources is easy as well:
public void wizardFinished(WizardModelEvent e) {
Object value = data.getData("myKey");
//evaluate value and take appropriate action
}
|
|||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | ||||||||