Skip to main content

Wizard (netbeans)

No replies
greglev
Offline
Joined: 2010-08-20
Points: 0

Hi everyone,
I have 3 Wizardpages: AnimaltypPage.class, TreePage.class, DetailsPage.class
when I am in the DetailPage ( 3th 'wizardpage), I need the node, that I selected in the second page (TreePage.class). How can I find that?.

public class WizardMain {<br />
	final Class[] pages = new Class[]{ AnimaltypPage.class, TreePage.class, DetailsPage.class };<br />
	public WizardMain(){<br />
		try {<br />
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());<br />
	    } catch (Exception e) {<br />
	            e.printStackTrace();<br />
	    }<br />
		Runnable r = new Runnable (){<br />
			public void run (){<br />
				Wizard wizard = WizardPage.createWizard("Probe", pages);<br />
				WizardDisplayer.showWizard (wizard, new Rectangle (20, 20, 700, 520));<br />
				System.exit (0);<br />
			}<br />
		};</p>
<p>		EventQueue.invokeLater (r);<br />
	}<br />
	public static void main(String[] args) {<br />
		new WizardMain();<br />
	}<br />
}

public class AnimaltypPage{
......
}

public class TreePage extends WizardPage{<br />
	private JTree tree;<br />
	public TreeWCFPage(){<br />
		setLayout(new BorderLayout());<br />
        initComponents();<br />
	}<br />
	public void initComponents(){<br />
		TreeModelExtractor converter = TreeModelExtractor.getInstance();<br />
		tree = new JTree(converter.getTreeForElement(TreeModelExtractor.GROUP, false, true));//Modell<br />
		tree.setRootVisible(true);<br />
		JScrollPane treeView = new JScrollPane(tree);<br />
		add(treeView, BorderLayout.CENTER);<br />
		tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);<br />
		setProblem("Wählen Sie ein Node aus!");<br />
		tree.addTreeSelectionListener(new TreeSelectionListener(){<br />
			@Override<br />
			public void valueChanged(TreeSelectionEvent ae) {<br />
				DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();<br />
				if(node == null)<br />
					return;<br />
				System.out.println(node.toString()+ " (" +node.getLevel() + ")");<br />
			}<br />
		});<br />
	}<br />
	protected String validateContents (Component comp, Object o){<br />
		if (tree.isSelectionEmpty())<br />
			return "Wählen Sie einen Typ aus!";<br />
		else<br />
			return null;<br />
	}<br />
	public static final String getDescription (){<br />
	      return "Feld";<br />
	}<br />
}

public class AnimaltypPage{
......
}

Message was edited by: greglev