Java/Swing Components/Wizard

Материал из Java эксперт
Перейти к: навигация, поиск

A dialog that presents the user with a sequence of steps for completing a task.

   <source lang="java">

import java.awt.BorderLayout; import java.awt.Container; import java.awt.LayoutManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JPanel; /**

* A dialog that presents the user with a sequence of steps for completing a
* task. The dialog contains "Next" and "Previous" buttons, allowing the user to
* navigate through the task.
*

* When the user backs up by one or more steps, the dialog keeps the completed * steps so that they can be reused if the user doesn"t change anything - this * handles the cases where the user backs up a few steps just to review what has * been completed. * <p> * But if the user changes some options in an earlier step, then the dialog may * have to discard the later steps and have them repeated. * <P> * THIS CLASS IS NOT WORKING CORRECTLY YET. * * * @author David Gilbert */ public class WizardDialog extends JDialog implements ActionListener { /** The end result of the wizard sequence. */ private Object result; /** The current step in the wizard process (starting at step zero). */ private int step; /** A reference to the current panel. */ private WizardPanel currentPanel; /** * A list of references to the panels the user has already seen - used for * navigating through the steps that have already been completed. */ private java.util.List panels; /** A handy reference to the "previous" button. */ private JButton previousButton; /** A handy reference to the "next" button. */ private JButton nextButton; /** A handy reference to the "finish" button. */ private JButton finishButton; /** A handy reference to the "help" button. */ private JButton helpButton; /** * Standard constructor - builds and returns a new WizardDialog. * * @param owner * the owner. * @param modal * modal? * @param title * the title. * @param firstPanel * the first panel. */ public WizardDialog(final JDialog owner, final boolean modal, final String title, final WizardPanel firstPanel) { super(owner, title + " : step 1", modal); this.result = null; this.currentPanel = firstPanel; this.step = 0; this.panels = new ArrayList(); this.panels.add(firstPanel); setContentPane(createContent()); } /** * Standard constructor - builds a new WizardDialog owned by the specified * JFrame. * * @param owner * the owner. * @param modal * modal? * @param title * the title. * @param firstPanel * the first panel. */ public WizardDialog(final JFrame owner, final boolean modal, final String title, final WizardPanel firstPanel) { super(owner, title + " : step 1", modal); this.result = null; this.currentPanel = firstPanel; this.step = 0; this.panels = new ArrayList(); this.panels.add(firstPanel); setContentPane(createContent()); } /** * Returns the result of the wizard sequence. * * @return the result. */ public Object getResult() { return this.result; } /** * Returns the total number of steps in the wizard sequence, if this number is * known. Otherwise this method returns zero. Subclasses should override this * method unless the number of steps is not known. * * @return the number of steps. */ public int getStepCount() { return 0; } /** * Returns true if it is possible to back up to the previous panel, and false * otherwise. * * @return boolean. */ public boolean canDoPreviousPanel() { return (this.step > 0); } /** * Returns true if there is a "next" panel, and false otherwise. * * @return boolean. */ public boolean canDoNextPanel() { return this.currentPanel.hasNextPanel(); } /** * Returns true if it is possible to finish the sequence at this point * (possibly with defaults for the remaining entries). * * @return boolean. */ public boolean canFinish() { return this.currentPanel.canFinish(); } /** * Returns the panel for the specified step (steps are numbered from zero). * * @param step * the current step. * * @return the panel. */ public WizardPanel getWizardPanel(final int step) { if (step < this.panels.size()) { return (WizardPanel) this.panels.get(step); } else { return null; } } /** * Handles events. * * @param event * the event. */ public void actionPerformed(final ActionEvent event) { final String command = event.getActionCommand(); if (command.equals("nextButton")) { next(); } else if (command.equals("previousButton")) { previous(); } else if (command.equals("finishButton")) { finish(); } } /** * Handles a click on the "previous" button, by displaying the previous panel * in the sequence. */ public void previous() { if (this.step > 0) { final WizardPanel previousPanel = getWizardPanel(this.step - 1); // tell the panel that we are returning previousPanel.returnFromLaterStep(); final Container content = getContentPane(); content.remove(this.currentPanel); content.add(previousPanel); this.step = this.step - 1; this.currentPanel = previousPanel; setTitle("Step " + (this.step + 1)); enableButtons(); pack(); } } /** * Displays the next step in the wizard sequence. */ public void next() { WizardPanel nextPanel = getWizardPanel(this.step + 1); if (nextPanel != null) { if (!this.currentPanel.canRedisplayNextPanel()) { nextPanel = this.currentPanel.getNextPanel(); } } else { nextPanel = this.currentPanel.getNextPanel(); } this.step = this.step + 1; if (this.step < this.panels.size()) { this.panels.set(this.step, nextPanel); } else { this.panels.add(nextPanel); } final Container content = getContentPane(); content.remove(this.currentPanel); content.add(nextPanel); this.currentPanel = nextPanel; setTitle("Step " + (this.step + 1)); enableButtons(); pack(); } /** * Finishes the wizard. */ public void finish() { this.result = this.currentPanel.getResult(); setVisible(false); } /** * Enables/disables the buttons according to the current step. A good idea * would be to ask the panels to return the status... */ private void enableButtons() { this.previousButton.setEnabled(this.step > 0); this.nextButton.setEnabled(canDoNextPanel()); this.finishButton.setEnabled(canFinish()); this.helpButton.setEnabled(false); } /** * Checks, whether the user cancelled the dialog. * * @return false. */ public boolean isCancelled() { return false; } /** * Creates a panel containing the user interface for the dialog. * * @return the panel. */ public JPanel createContent() { final JPanel content = new JPanel(new BorderLayout()); content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); content.add((JPanel) this.panels.get(0)); final L1R3ButtonPanel buttons = new L1R3ButtonPanel("Help", "Previous", "Next", "Finish"); this.helpButton = buttons.getLeftButton(); this.helpButton.setEnabled(false); this.previousButton = buttons.getRightButton1(); this.previousButton.setActionCommand("previousButton"); this.previousButton.addActionListener(this); this.previousButton.setEnabled(false); this.nextButton = buttons.getRightButton2(); this.nextButton.setActionCommand("nextButton"); this.nextButton.addActionListener(this); this.nextButton.setEnabled(true); this.finishButton = buttons.getRightButton3(); this.finishButton.setActionCommand("finishButton"); this.finishButton.addActionListener(this); this.finishButton.setEnabled(false); buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); content.add(buttons, BorderLayout.SOUTH); return content; } } /* * JCommon : a free general purpose class library for the Java(tm) platform * * * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jcommon/index.html * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. in the * United States and other countries.] * * ---------------- WizardPanel.java ---------------- (C) Copyright 2000-2004, * by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); Contributor(s): -; * * $Id: WizardPanel.java,v 1.5 2007/11/02 17:50:36 taqua Exp $ * * Changes (from 26-Oct-2001) -------------------------- 26-Oct-2001 : Changed * package to com.jrefinery.ui.*; 14-Oct-2002 : Fixed errors reported by * Checkstyle (DG); * */ /** * A panel that provides the user interface for a single step in a WizardDialog. * * @author David Gilbert */ abstract class WizardPanel extends JPanel { /** The owner. */ private WizardDialog owner; /** * Creates a new panel. * * @param layout * the layout manager. */ protected WizardPanel(final LayoutManager layout) { super(layout); } /** * Returns a reference to the dialog that owns the panel. * * @return the owner. */ public WizardDialog getOwner() { return this.owner; } /** * Sets the reference to the dialog that owns the panel (this is called * automatically by the dialog when the panel is added to the dialog). * * @param owner * the owner. */ public void setOwner(final WizardDialog owner) { this.owner = owner; } /** * Returns the result. * * @return the result. */ public Object getResult() { return null; } /** * This method is called when the dialog redisplays this panel as a result of * the user clicking the "Previous" button. Inside this method, subclasses * should make a note of their current state, so that they can decide what to * do when the user hits "Next". */ public abstract void returnFromLaterStep(); /** * Returns true if it is OK to redisplay the last version of the next panel, * or false if a new version is required. * * @return boolean. */ public abstract boolean canRedisplayNextPanel(); /** * Returns true if there is a next panel. * * @return boolean. */ public abstract boolean hasNextPanel(); /** * Returns true if it is possible to finish from this panel. * * @return boolean. */ public abstract boolean canFinish(); /** * Returns the next panel in the sequence, given the current user input. * Returns null if this panel is the last one in the sequence. * * @return the next panel in the sequence. */ public abstract WizardPanel getNextPanel(); } /* * JCommon : a free general purpose class library for the Java(tm) platform * * * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jcommon/index.html * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. in the * United States and other countries.] * * -------------------- L1R3ButtonPanel.java -------------------- (C) Copyright * 2000-2004, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); Contributor(s): -; * * $Id: L1R3ButtonPanel.java,v 1.5 2007/11/02 17:50:36 taqua Exp $ * * Changes (from 26-Oct-2001) -------------------------- 26-Oct-2001 : Changed * package to com.jrefinery.ui.* (DG); 26-Jun-2002 : Removed unnecessary import * (DG); 14-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ /** * A "ready-made" panel that has one button on the left and three buttons on the * right - nested panels and layout managers take care of resizing. * * @author David Gilbert */ class L1R3ButtonPanel extends JPanel { /** The left button. */ private JButton left; /** The first button on the right of the panel. */ private JButton right1; /** The second button on the right of the panel. */ private JButton right2; /** The third button on the right of the panel. */ private JButton right3; /** * Standard constructor - creates panel with the specified button labels. * * @param label1 * the label for button 1. * @param label2 * the label for button 2. * @param label3 * the label for button 3. * @param label4 * the label for button 4. */ public L1R3ButtonPanel(final String label1, final String label2, final String label3, final String label4) { setLayout(new BorderLayout()); // create the pieces... final JPanel panel = new JPanel(new BorderLayout()); final JPanel panel2 = new JPanel(new BorderLayout()); this.left = new JButton(label1); this.right1 = new JButton(label2); this.right2 = new JButton(label3); this.right3 = new JButton(label4); // ...and put them together panel.add(this.left, BorderLayout.WEST); panel2.add(this.right1, BorderLayout.EAST); panel.add(panel2, BorderLayout.CENTER); panel.add(this.right2, BorderLayout.EAST); add(panel, BorderLayout.CENTER); add(this.right3, BorderLayout.EAST); } /** * Returns a reference to button 1, allowing the caller to set labels, * action-listeners etc. * * @return the left button. */ public JButton getLeftButton() { return this.left; } /** * Returns a reference to button 2, allowing the caller to set labels, * action-listeners etc. * * @return the right button 1. */ public JButton getRightButton1() { return this.right1; } /** * Returns a reference to button 3, allowing the caller to set labels, * action-listeners etc. * * @return the right button 2. */ public JButton getRightButton2() { return this.right2; } /** * Returns a reference to button 4, allowing the caller to set labels, * action-listeners etc. * * @return the right button 3. */ public JButton getRightButton3() { return this.right3; } } </source>

Dynamic Wizard Dialog

   <source lang="java">

package jwizardcomponent.example; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JLabel; import javax.swing.JRadioButton; import javax.swing.ButtonGroup; import jwizardcomponent.Utilities; import jwizardcomponent.JWizardPanel; import jwizardcomponent.JWizardComponents; import jwizardcomponent.frame.JWizardFrame; /**

* <p>Title: JWizardComponent

*

Description: Swing-Based Wizard Framework for Wizards

*

Copyright (C) 2003 William Ready * *
This library is free software; you can redistribute it and/or *
modify it under the terms of the GNU Lesser General Public *
License as published by the Free Software Foundation; either *
version 2.1 of the License, or (at your option) any later version. * *
This library is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Lesser General Public License for more details. * *
To receive a copy of the GNU Lesser General Public License *
write to: The Free Software Foundation, Inc., *
59 Temple Place, Suite 330 *
Boston, MA 02111-1307 USA

* @author Piotr Kaminski
* @version 1.0
*/

public class DynamicJWizard extends JWizardFrame {

   public static final int PANEL_FIRST = 0;
   public static final int PANEL_CHOOSER = 1;
   public static final int PANEL_OPTION_A = 2;
   public static final int PANEL_OPTION_B = 3;
   public static final int PANEL_LAST = 4;
   
   public DynamicJWizard() {
       super();
       init();
   }
   
   private void init() {
       this.setTitle("Dynamic JWizardComponent example");
       
       JWizardPanel panel = null;
       
       panel = new FirstWizardPanel(getWizardComponents());
       getWizardComponents().addWizardPanel(PANEL_FIRST, panel);
       
       panel = new ChooserWizardPanel(getWizardComponents());
       getWizardComponents().addWizardPanel(PANEL_CHOOSER, panel);
       
       panel = new OptionWizardPanel(getWizardComponents(), "A");
       getWizardComponents().addWizardPanel(PANEL_OPTION_A, panel);
       
       panel = new OptionWizardPanel(getWizardComponents(), "B");
       getWizardComponents().addWizardPanel(PANEL_OPTION_B, panel);
       
       panel = new LastWizardPanel(getWizardComponents());
       getWizardComponents().addWizardPanel(PANEL_LAST, panel);
       
       setSize(500, 300);
       Utilities.centerComponentOnScreen(this);
   }
   
   public static void main(String [] args) {
       DynamicJWizard wizard = new DynamicJWizard();
       wizard.setVisible(true);
   }

} class LabelWizardPanel extends JWizardPanel {

   public LabelWizardPanel(JWizardComponents wizardComponents, String label) {
       super(wizardComponents);
       this.setLayout(new GridBagLayout());
       this.add(new JLabel(label)
       , new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
       , GridBagConstraints.CENTER, GridBagConstraints.BOTH
       , new Insets(0, 0, 0, 0), 0, 0));
   }

} class FirstWizardPanel extends LabelWizardPanel {

   public FirstWizardPanel(JWizardComponents wizardComponents) {
       super(wizardComponents, "First panel");
       setPanelTitle("First simple static panel");
   }

} class ChooserWizardPanel extends JWizardPanel {

   private JRadioButton optionARadioButton;
   private JRadioButton optionBRadioButton;
   private JRadioButton optionFRadioButton;
   private ButtonGroup bg;
   private char selectedOption = "N"; // "N" is no option selected
   // "A", "B" & "F" stands for options
   public ChooserWizardPanel(JWizardComponents wizardComponents) {
       super(wizardComponents, "Choose option A or B or F for finish ");
       init();
   }
   private void init() {
       optionARadioButton = new JRadioButton();
       optionBRadioButton = new JRadioButton();
       optionFRadioButton = new JRadioButton();
       ButtonGroup bg = new ButtonGroup();
       bg.add(optionARadioButton);
       bg.add(optionBRadioButton);
       bg.add(optionFRadioButton);
       this.setLayout(new GridBagLayout());
       
       this.add(optionARadioButton
       , new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
       , GridBagConstraints.WEST, GridBagConstraints.BOTH
       , new Insets(0, 0, 0, 0), 0, 0));
       optionARadioButton.addItemListener(new ItemListener() {
           public void itemStateChanged(ItemEvent e) {
               if (e.getStateChange() == ItemEvent.SELECTED) {
                   selectedOption = "A";
                   update();
               }
           }
       });
       this.add(new JLabel("Choose option A")
       , new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
       , GridBagConstraints.WEST, GridBagConstraints.BOTH
       , new Insets(0, 0, 0, 0), 0, 0));
       
       this.add(optionBRadioButton,
       new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
       , GridBagConstraints.WEST, GridBagConstraints.BOTH
       , new Insets(0, 0, 0, 0), 0, 0));
       optionBRadioButton.addItemListener(new ItemListener() {
           public void itemStateChanged(ItemEvent e) {
               if (e.getStateChange() == ItemEvent.SELECTED) {
                   selectedOption = "B";
                   update();
               }
           }
       });
       this.add(new JLabel("Choose option B")
       , new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
       , GridBagConstraints.WEST, GridBagConstraints.BOTH
       , new Insets(0, 0, 0, 0), 0, 0));
       
       this.add(optionFRadioButton,
       new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
       , GridBagConstraints.WEST, GridBagConstraints.BOTH
       , new Insets(0, 0, 0, 0), 0, 0));
       optionFRadioButton.addItemListener(new ItemListener() {
           public void itemStateChanged(ItemEvent e) {
               if (e.getStateChange() == ItemEvent.SELECTED) {
                   selectedOption = "F";
                   update();
               }
           }
       });
       this.add(new JLabel("Choose option F")
       , new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
       , GridBagConstraints.WEST, GridBagConstraints.BOTH
       , new Insets(0, 0, 0, 0), 0, 0));
   }
   
   public void update() {
       setNextButtonEnabled((selectedOption == "A") || (selectedOption == "B") );
       setFinishButtonEnabled(selectedOption == "F");
       setBackButtonEnabled(false); // there is no way back
   }
   
   public void next() {
       if (selectedOption == "A") {
           switchPanel(DynamicJWizard.PANEL_OPTION_A);
       } else if (selectedOption == "B") {
           switchPanel(DynamicJWizard.PANEL_OPTION_B);
       }
   }
   public void back() {
   }

} class OptionWizardPanel extends LabelWizardPanel {

   public OptionWizardPanel(JWizardComponents wizardComponents, String option) {
       super(wizardComponents, "Option " + option + " was choosed");
       setPanelTitle("Option " + option + " panel");
   }
   public void next() {
       switchPanel(DynamicJWizard.PANEL_LAST);
   }
   public void back() {
       switchPanel(DynamicJWizard.PANEL_CHOOSER);
   }

} class LastWizardPanel extends LabelWizardPanel {

   public LastWizardPanel(JWizardComponents wizardComponents) {
       super(wizardComponents, "Last panel, you can finish now");
       setPanelTitle("Last simple static panel");
   }

}


 </source>
   
  
 
  



Simple Dynamic Logo Wizard

   <source lang="java">

package jwizardcomponent.example; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import javax.swing.UIManager; import jwizardcomponent.DefaultJWizardComponents; import jwizardcomponent.Utilities; import jwizardcomponent.frame.SimpleLogoJWizardFrame; /**

*

Title: JWizardComponent

*

Description: Swing-Based Wizard Framework for Wizards

*

Copyright (C) 2003 William Ready * *
This library is free software; you can redistribute it and/or *
modify it under the terms of the GNU Lesser General Public *
License as published by the Free Software Foundation; either *
version 2.1 of the License, or (at your option) any later version. * *
This library is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Lesser General Public License for more details. * *
To receive a copy of the GNU Lesser General Public License *
write to: The Free Software Foundation, Inc., *
59 Temple Place, Suite 330 *
Boston, MA 02111-1307 USA

* @author William Ready
* @version 1.0
*/

public class SimpleDynamicLogoJWizard {

 static ImageIcon LOGO;
 public static void main(String [] args) {
   try {
     
     LOGO =
     new ImageIcon(DefaultJWizardComponents.class.getResource("images/logo.jpeg"));
     SimpleLogoJWizardFrame wizardFrame = new SimpleLogoJWizardFrame(
         LOGO);
     wizardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     SwingUtilities.updateComponentTreeUI(wizardFrame);
     
     wizardFrame.setTitle("Simple Logo Dynamic JWizardComponent");
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Dynamic Test")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleDynamicWizardPanel(wizardFrame.getWizardComponents()));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Done!")));
     wizardFrame.setSize(500, 300);
     Utilities.centerComponentOnScreen(wizardFrame);
     wizardFrame.show();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }

}


 </source>
   
  
 
  



Simple Dynamic Wizard

   <source lang="java">

package jwizardcomponent.example; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import javax.swing.UIManager; import jwizardcomponent.Utilities; import jwizardcomponent.frame.SimpleJWizardFrame; /**

*

Title: JWizardComponent

*

Description: Swing-Based Wizard Framework for Wizards

*

Copyright (C) 2003 William Ready * *
This library is free software; you can redistribute it and/or *
modify it under the terms of the GNU Lesser General Public *
License as published by the Free Software Foundation; either *
version 2.1 of the License, or (at your option) any later version. * *
This library is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Lesser General Public License for more details. * *
To receive a copy of the GNU Lesser General Public License *
write to: The Free Software Foundation, Inc., *
59 Temple Place, Suite 330 *
Boston, MA 02111-1307 USA

* @author William Ready
* @version 1.0
*/

public class SimpleDynamicJWizard extends SimpleJWizardFrame {

 public static void main(String [] args) {
   try {
     SimpleJWizardFrame wizardFrame = new SimpleJWizardFrame();
     wizardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     SwingUtilities.updateComponentTreeUI(wizardFrame);
     wizardFrame.setTitle("Simple Dynamic JWizardComponent");
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Dynamic Test")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleDynamicWizardPanel(wizardFrame.getWizardComponents()));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Done!")));
     wizardFrame.setSize(500, 300);
     Utilities.centerComponentOnScreen(wizardFrame);
     wizardFrame.show();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }

}


 </source>
   
  
 
  



Simple Modal Logo Wizard

   <source lang="java">

package jwizardcomponent.example; import java.awt.BorderLayout; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; import jwizardcomponent.Utilities; import jwizardcomponent.dialog.*; /**

*

Title: JWizardComponent

*

Description: Swing-Based Wizard Framework for Wizards

*

Copyright (C) 2003 William Ready * *
This library is free software; you can redistribute it and/or *
modify it under the terms of the GNU Lesser General Public *
License as published by the Free Software Foundation; either *
version 2.1 of the License, or (at your option) any later version. * *
This library is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Lesser General Public License for more details. * *
To receive a copy of the GNU Lesser General Public License *
write to: The Free Software Foundation, Inc., *
59 Temple Place, Suite 330 *
Boston, MA 02111-1307 USA

*
* @author Jens Kutschke, jens.kutschke@j-dimension.ru, http://www.j-dimension.ru
*
* @version 1.0
*/

public class SimpleModalLogoJWizard {

   static ImageIcon LOGO;
   
   public static void main(String [] args) {
       try {
           
           // optional: set a look and feel
           UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
           
           // create a new frame or use an existing one of your application
           final JFrame mainWindow=new JFrame("Simple demo of a modal wizard with a logo icon.");
           mainWindow.getContentPane().setLayout(new BorderLayout());
           mainWindow.getContentPane().add("North", new JLabel("Click the button to get a modal wizard dialog for this JFrame.", JLabel.CENTER));
           
           // in this example, we use a button to open a new wizard
           JButton dialogButton=new JButton("open modal wizard");
           dialogButton.addActionListener(new java.awt.event.ActionListener() {
               public void actionPerformed(java.awt.event.ActionEvent e) {
                   
                   // create the modal wizard: the constructor takes the parent frame
                   SimpleLogoJWizardDialog wizardDialog = new SimpleLogoJWizardDialog(mainWindow, LOGO, true);
                   
                   SwingUtilities.updateComponentTreeUI(wizardDialog);
                   wizardDialog.setTitle("Simple Logo JWizardComponent");
                   
                   // add panels to the wizard
                   wizardDialog.getWizardComponents().addWizardPanel(
                   new SimpleLabelWizardPanel(wizardDialog.getWizardComponents(),
                   new JLabel("This")));
                   wizardDialog.getWizardComponents().addWizardPanel(
                   new SimpleLabelWizardPanel(wizardDialog.getWizardComponents(),
                   new JLabel("is")));
                   wizardDialog.getWizardComponents().addWizardPanel(
                   new SimpleLabelWizardPanel(wizardDialog.getWizardComponents(),
                   new JLabel("a")));
                   wizardDialog.getWizardComponents().addWizardPanel(
                   new SimpleLabelWizardPanel(wizardDialog.getWizardComponents(),
                   new JLabel("modal")));
                   wizardDialog.getWizardComponents().addWizardPanel(
                   new SimpleLabelWizardPanel(wizardDialog.getWizardComponents(),
                   new JLabel("wizard!")));
                   wizardDialog.setSize(500, 300);
                   wizardDialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                   Utilities.centerComponentOnScreen(wizardDialog);
                   
                   // show the wizard
                   wizardDialog.show();
               }
           });
           mainWindow.getContentPane().add("South", dialogButton);
           mainWindow.setSize(400,  100);
           mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           
           LOGO =
           new ImageIcon("images/logo.jpeg");
           
           // show the frame
           mainWindow.show();
           
       } catch (Exception e) {
           e.printStackTrace();
       }
   }
   

}


 </source>
   
  
 
  



Simple Wizard

   <source lang="java">

package jwizardcomponent.example; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import javax.swing.UIManager; import jwizardcomponent.Utilities; import jwizardcomponent.frame.SimpleJWizardFrame; /**

*

Title: JWizardComponent

*

Description: Swing-Based Wizard Framework for Wizards

*

Copyright (C) 2003 William Ready * *
This library is free software; you can redistribute it and/or *
modify it under the terms of the GNU Lesser General Public *
License as published by the Free Software Foundation; either *
version 2.1 of the License, or (at your option) any later version. * *
This library is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Lesser General Public License for more details. * *
To receive a copy of the GNU Lesser General Public License *
write to: The Free Software Foundation, Inc., *
59 Temple Place, Suite 330 *
Boston, MA 02111-1307 USA

* @author William Ready
* @version 1.0
*/

public class SimpleJWizard extends SimpleJWizardFrame {

 public static void main(String [] args) {
   try {
     SimpleJWizardFrame wizardFrame = new SimpleJWizardFrame();
     wizardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     SwingUtilities.updateComponentTreeUI(wizardFrame);
     wizardFrame.setTitle("Simple JWizardComponent");
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Yo")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("This")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Is")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("A")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Test!")));
     wizardFrame.setSize(500, 300);
     Utilities.centerComponentOnScreen(wizardFrame);
     wizardFrame.show();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }

}


 </source>
   
  
 
  



Swing Wizard component from yuvraj_sawant(at)persistent.co.in

   <source lang="java">

Attachment Details: 1) MyWizardArchitectureExample.zip cosists an example for implementing a wizard using the supplied Wizard.jar 2) Wizard.jar implements the architecture for swing wizard. 3) doc.zip consists of java docs for this wizard architecture implementation. 4) SwingWizardArchitecture.zip for the source code.


 </source>
   
  
 
  



Swing Wizard component with source code

   <source lang="java">

package jwizardcomponent.example; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import javax.swing.UIManager; import jwizardcomponent.Utilities; import jwizardcomponent.frame.SimpleJWizardFrame; import jwizardcomponent.frame.SimpleLogoJWizardFrame; /**

*

Title: JWizardComponent

*

Description: Swing-Based Wizard Framework for Wizards

*

Copyright (C) 2003 William Ready * *
This library is free software; you can redistribute it and/or *
modify it under the terms of the GNU Lesser General Public *
License as published by the Free Software Foundation; either *
version 2.1 of the License, or (at your option) any later version. * *
This library is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Lesser General Public License for more details. * *
To receive a copy of the GNU Lesser General Public License *
write to: The Free Software Foundation, Inc., *
59 Temple Place, Suite 330 *
Boston, MA 02111-1307 USA

* @author William Ready
* @version 1.0
*/

public class SimpleLogoJWizard extends SimpleJWizardFrame {

 static ImageIcon LOGO;
 public static void main(String [] args) {
   try {
       LOGO =
           new ImageIcon("images/logo.jpeg");
     SimpleLogoJWizardFrame wizardFrame = new SimpleLogoJWizardFrame(
         LOGO);
     wizardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
     SwingUtilities.updateComponentTreeUI(wizardFrame);
     wizardFrame.setTitle("Simple Logo JWizardComponent");
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Yo")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("This")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Is")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("A")));
     wizardFrame.getWizardComponents().addWizardPanel(
         new SimpleLabelWizardPanel(wizardFrame.getWizardComponents(),
         new JLabel("Test!")));
     wizardFrame.setSize(500, 300);
     Utilities.centerComponentOnScreen(wizardFrame);
     wizardFrame.show();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }

}


 </source>