Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

Search: 

  Tutorial: Creating Wizard Dialogs with Java Swing

Wizard dialogs are ubiquitous in today's desktop applications. This article creates a framework for a simple wizard dialog, complete with Back, Next, and Cancel buttons that you can extend for use in your applications as necessary.

Tutorial Details:

Wizard dialogs are ubiquitous in today's desktop applications. What exactly is a wizard dialog? Well, you've likely run across several wizard dialogs already, either when you're installing a pre-packaged application, or you're configuring a series of program options. In this article, I will create a framework for a simple wizard dialog that you can extend as necessary.

A wizard dialog is constructed with a number of panels, and each panel contains user-configurable components such as radio buttons, sliders, or text fields. The idea here is that the application user, by pressing either the Next or Back buttons, can "flip" across these panels, entering information on each one until he or she completes the path. At this point, the Next button often changes to a Finish button, and when pressed, the dialog will close. The instantiating class should then be able to retrieve all of the data that was entered. At any time, the user can also press the Cancel button to quit the dialog and discard any data that has been entered so far.

Seems like a simple design, right? Well, not necessarily. Here are a few design considerations that must be kept in mind.

First, note that wizard dialogs do not necessarily traverse across their panels in a linear fashion. In other words, if a wizard dialog has Panels 1 through 5, pressing the Next button four times may take you from Panel 1 to Panel 5, traversing across Panels 2, 3, and 4. But that's not always the case. For example, what happens if Panel 3 tries to connect to a remote server and cannot make the connection? In that case, the wizard may need to branch off to another series of panels which takes the user through a setup without connecting to the server. And when you add several possible such branches into the equation, you begin to see that wizard panels must be connected in a tree-like fashion, where you start at the beginning (the trunk) and move your way down branches until you reach a terminable leaf, at which point the Next button should change to a Finish and the wizard dialog ends.


Second, the Next and Back (and even sometimes the Cancel) buttons may need to be disabled. At the initial panel, the Back button should always be disabled - after all, there's no previous panel to go back to. However, there are other cases where the Next button should be disabled. Validating user entry is the traditional example of this. Let's say that a panel is asking a user to enter their password twice using two Swing JPasswordField components. (This sort of password entry, where the entered characters are masked with asterisks, is fairly common.) In this case, the dialog should not enable the Next button until the passwords in both fields match. This ensures that user does not continue in the wizard until they have a valid password, but anyone looking over the user's shoulder cannot see the password.


Third, data that has been entered must remain persistent if the user goes back across the panels. Again, this isn't hard, so long as the data remains in memory. However, there's some logic to keep in mind here as well. Let's again look at the example of Panel 3 connecting and transmitting data to a server. If the user goes backwards from Panel 4, they should not jump immediately to a panel that re-transmits the exact same data to the server. Instead, they need to skip over the step that actually transmits the data and jump to Panel 2 where data can be re-entered.
If you're getting the impression that numbering our panels with an integer code is a bad idea, that's exactly right. It's often better to give each panel an Object identifier, such as a string. Then, when we need to move forward or backward, we can ask the current panel for the identifier of the next panel or the previous panel that it should traverse to. Note that the next and previous panel identifiers returned by the current panel are not guaranteed to remain constant, and may change based on context and user input.

So, with those design considerations in mind, let's outline a set of classes that we're going to write to create our extensible wizard dialog.


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Creating Wizard Dialogs with Java Swing

View Tutorial:
Creating Wizard Dialogs with Java Swing

Related Tutorials:

Displaying 1 - 50 of about 3864 Related Tutorials.

Creating Check Box in Java Swing
Code Java Creating Check Box in Java Swing... Swing. In this section, you can learn simply creating the Check Box in Java Swing. Check Boxes are created in swing by creating the instance of the JCheckBox
 
Creating a JTabbedPane Container in Java Swing
JTabbedpane Examples,Tabbed Pane Java,Tab Pane Java,Creating a JTabbedPane Container Creating a JTabbedPane Container in Java... the JTabbedPane container in Java Swing. The example for illustration is given in which
 
Java Swing
Java Swing Components,Swing GUI Components,Java Components Example - Java Swing Tutorials Java Swing   ... learning AWT, lets now see what's Swing? Well, Swing is important to develop Java
 
Java Swing
Java Swing,Java Swing Tutorials,Swing Example Java,Online Swing Tutorials,Swing Example Code Java Java Swing Tutorials...; Java Swing tutorials -  Here you will find many Java Swing
 
Java Swing Tutorials
Java Swing,Java Swing Tutorials,Swing Example Java,Online Swing Tutorials,Swing Example Code Java Java Swing Tutorials...; Java Swing tutorials -  Here you will find many Java Swing
 
Java Swing Tutorials
Java Swing,Java Swing Tutorials,Swing Example Java,Online Swing Tutorials,Swing Example Code Java Java Swing Tutorials...; Java Swing tutorials -  Here you will find many Java Swing
 
JSlider Component of Java Swing
Java Slider Example,Java JSlider,Slider Component in Java Swing,JSlider Source Code Java JSlider Component of Java Swing... of Java Swing. A Slider is a Swing tool which you can use for selecting a range
 
Java Swing Tutorials
Java Swing,Java Swing Tutorials,Swing Example Java,Online Swing Tutorials,Swing Example Code Java Java Swing Tutorials...; Java Swing tutorials -  Here you will find many Java Swing
 
What is Java Swing?
What is Java Swing,Definition of Java Swings,Java Swing API What is Java Swing?      ... the Java swing. The Java Swing provides the multiple platform independent APIs
 
Creating a Frame
Creating a Frame,Java Frame Example,Java Swing Frame,How to Create Java Frame Creating a Frame : Swing Tutorials...; This program shows you how to create a frame in Java Swing Application
 
Sum of a Number using Swing
Sum of a Number using Swing Sum of a Number using Swing           ... using swing. JTextField, JButton is a component of GUI. Brief description
 
Creating a JTable Component
flexible Java Swing component that allows the user to store, show and edit the data... of  two-dimensional tabular format. The Java swing implements tables by using... data from an object that implements the TableModel interface of java swing
 
Java Swing
Java Swing Java Swing   ... at: http:/www.roseindia.net/java/example/java/swing/swing.shtml   ...;            Swing works
 
JOptionPane - Simple Dialogs
Java: JOptionPane - Simple Dialogs Prev: none | Next: JOptionPane - More Dialogs Java: JOptionPane - Simple Dialogs Here are two useful static methods from
 
JOptionPane - More Dialogs
Java: JOptionPane - More Dialogs Prev: JOptionPane - Simple Dialogs | Next: none Java: JOptionPane - More Dialogs Here are some more useful static methods from
 
Demonstrates Wizard
Demonstrates Wizard Demonstrates Wizard...;  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
 
Progress Bar in Java Swing
Swing Progress Bar,Java Progress Bar Example,How to Create Progressbar in Java Progress Bar in Java Swing  ...; In this section, you can learn how to handle progress bar in java swing
 
Chess Application In Java Swing
Chess Application In Java Swing Chess Application In Java Swing         ... game in java swing. In the given example, we have defined MouseListener
 
Swing Jobs at Rose India
Swing Job,Swing Jobs at RoseIndia.net,Java Swing Job... experience in Java, using Swing components. Job Description for Java Swing... with every aspect of developing application using Java Swing
 
Swing Applet Example in java
Java Swing Applet,Java Swing Applets,Swing Applet Tutorials,Swing Applet Example Java Java - Swing Applet Example in java...; Introduction In this section we will show you about using swing
 
Create a ToolBar in Java
; In this section, you will learn how to create toolbar in java. Swing... JToolbar Example,Java Toolbar,Create Toolbar Icons Java,How to Create Tool Bar in Java Create a ToolBar in Java
 
The Dialog boxes
Creating Wizard Dialogs with Java Swing (http://java.sun.com... Java: Dialogs Java: Dialogs There are several ways to build dialog boxes: JOptionPane
 
Print Screen Using Java Swing
print Screen Using Java Swing Print Screen Using Java Swing          ...;    In this section, you will learn how to print in java
 
Writing Calculator Program in Swing
in Calculator.java class. Calculator Code in Java Swing Please save the code... Writing Calculator program in Swing Writing Calculator Program in Swing        
 
Changing Look and Feel of Swing Application
Changing Look and Feel,Change Swing Look and Feel,Java Swing Look and Feel Example Changing Look and Feel of Swing Application... Swing Application. The look and feel feature of Java Swing provides more
 
GUI - Swing vs. AWT
Java: GUI - Swing vs. AWT Java: GUI - Swing vs. AWT The original graphical user interface (GUI... in almost all cases; an AWT continues to work in Java. Must choose between Swing
 
Jigloo SWT/Swing GUI Builder
Jigloo SWT/Swing GUI Builder Jigloo SWT/Swing GUI... is a plugin for the Eclipse Java IDE and WebSphere Studio, which allows you to build and manage both Swing and SWT GUI classes. Jigloo creates and manages code
 
Creating a JAR file in Java
Java Jar File,Creating Jar File,Java Jar File Code,Jar File Using Java Creating a JAR file in Java   ...; This section provides you to the creating a jar file through the java source code
 
Creating a Scrollable JTable
Scrollable JTable,Scroll Table Example Java,Scrolling JTable,Creating a Scrollable JTable Component Creating a Scrollable JTable : Swing Tutorials        
 
Create a JRadioButton Component in Java
Radio Button Component,Java Radio Button Example,Radio Button Code in Java Swing Create a JRadioButton Component in Java...; In this section, you will learn how to create a radio button in java
 
Scrollpane in Java Swing
Scrollpane in Java Swing Scrollpane in Java Swing          ...;    Use Canvas with ScrollPane in swing. In this section
 
Akrogen
of component. Wizard is composed of several different underlying pages. For instance, "New java class" wizard which can be accessed with File/New/Class menu is composed of wizard page which can generate "Java class" component. Whe you wish develop
 
Create a Scroll Pane Container in Java
container in Java Swing. When you simply create a Text Area and putting text... component of Java Swing. Following is the screen shot for the result... JScrollpane Container,Scrollpane Container in Java,Scroll Pane Container
 
Noise Image in Graphics
;   This Java Tutorial is all about creating Images with the use of graphics in Java. For this we have to import awt and swing package in our Java code. In this tutorial you will learn how to create a noise image
 
Noise Image in Graphics
;   This Java Tutorial is all about creating Images with the use of graphics in Java. For this we have to import awt and swing package in our Java code. In this tutorial you will learn how to create a noise image
 
Create a JList Component in Java
Jlist Java,List Box Example,Creating List Box Using Java Swing Create a JList Component in Java    ... the JComponent class in java swing. There has been using string array values
 
Show input dialog box
Swing Swing Input Dialog Box Example - Swing Dialogs... of Java Swing. You have been using the System.in for inputting anything from user. Java Swing provides the facility to input any thing (whether the text
 
Creating Trapezoid Using Java
Creating Trapezoid Using Java Creating Trapezoid Using Java         ... on PowerPoint slide using java. In this example, we are creating a slide
 
Create Layout Components in a Grid in Java
Create Layout Components in a Grid,How to Create Layout in Grid Using Java Swing Create Layout Components in a Grid in Java... with the help of grid in Java Swing. The grid layout provides the facility
 
Creating a ZIP file in Java
Creating a ZIP file in Java Creating a ZIP file in Java          ... of making it possible through you code in java application. Program Result
 
"Hello World" program in Swing and JRuby
"Hello World" program in Swing and JRuby "Hello World" program in Swing and JRuby   ...; In the previous section of JRuby Tutorials you have studied how to use Java classes in JRuby
 
Combo Box operation in Java Swing
using Java Combo Box operation in Java Swing... has used various java APIs for doing required are explained as follows: JComboBox...;  String items[] = {"Java", "JSP"
 
Customize the Icon in a JCheckBox Component of Java Swing
Customized Checkbox Java,Customize the Icon in a JCheckBox Component of Java Swing - Java Swing Tutorials Customize the Icon in a JCheckBox Component of Java Swing      
 
JFormDesigner
;   JFormDesigner is an innovative GUI designer for Java? Swing user.... Why use JFormDesigner? JFormDesigner makes Swing GUI design a real pleasure... and a prefix for keys when creating a new form and then forget about
 
Show the Value of Scroll Bar in Java Swing
Swing Show the Value of Scroll Bar in Java Swing... returns the horizontal scrollbar object in the JScrollPane component of Java Swing. Hence, the JScrollPane is used for another object of the Java Swing
 
Creating a Project
Creating a Project Creating a Project... on ?Java Project? and give a project name of your choice (?NewProject.... Now a window opens containing a java program with the main() method
 
Creating an InlineStreamFilter
Creating an InlineStreamFilter,XML,XML Tutorials,Online XML Tutorial,XML Help Tutorials Creating an InlineStreamFilter  ...; This Example shows you how to Create an InlineStream Filter. JAXP (Java API for XML
 
Creating Website with the use of template in Wicket
Creating Website with the use of template in Wicket Creating Website with the use of template in Wicket... Hello World", "creating Ajax Auto Completer" and some others very
 
Creating Blank DOM Document
XML,XML Tutorials,XML Examples,XML Example,Creating Blank DOM Document Creating Blank DOM Document    ... you how to create blank DOM document. JAXP (Java API for XML Processing
 
Creating a temporary file
Java Temporary File, Create Temporary Files, File Creation in Java Java Temporary File - Temporary File Creation in Java... close the java program or your JVM. Code of this program is given below
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.