tags:

views:

254

answers:

2

I am using the code given here to create my own wizard application.

The basic motive of moving from 1 screen to other is achieved with this. But now I am stuck at a point. The problem is... suppose I have entered some value on screen1 and then I move to screen2.. and on basis of values entered in screen1 I have to display some values on screen 2.. how do I get the values set in screen1 in screen2 using the same code given in the link.

I tried to study the code in detail, but couldn't understand as am fairly new to Java and also to Swing.

If someone has already used the same code to implement wizards, please do help me.

+2  A: 

You should store the state of your wizard in the WizardModel, and add getters and setters (i.e. like a JavaBean) appropriately. For example:

public class WizardModel {
   ...
   private String host;

   public void setHost(String host) {
       this.host = host;
   }

   public String getHost() {
       return host;
   }
}
David Grant
So do u mean that what ever variables i am using to store certain values.. they must be global? n defined in wizardmodel?
NewToJava
If you want to communicate them from one pane to another you have to store them somewhere which is "global" all all panes.
David Grant
okie.. So i was thinking in the right direction :) i had thought abt it.. but thought that there might be some other way of doint it.. also what do u mean exactly by saving the state of the wizard.. do u mean setting stuff to recognise that the wizard is at a particular screen.. ot is it smthingelse
NewToJava
you mit be feeling my questions foolish.. but i am absolutely new to tis.. n u can say.. i am learning java swing thru this exercise..
NewToJava
The controller knows which screen you're on (it in the example). By state, I mean the parameters you need to get from your wizard.
David Grant
ohhkie.. i will try out what you are directing towards.. and if i have nay other doubts will get back to you.. Thanks a lot for all your help though :)
NewToJava
A: 

Mr Potato Head (?) is right; the Model is where your data is stored.

For example code you may wish to look at Freedom for Media in Java which seems to have an implementation of WizardModel in the Documentation / Javadoc section, package net.sf.fmj.ui.wizard.

If you wish to have some more examples of Swing applications, and nicely layed-out forms, have a look at JGoodies. Even if you decide not to use their library the examples provided are worth reading.

extraneon
thanks a lot.. will surely have a look at the examples in the link.
NewToJava