USAGE OF JAVA WIZARD V 0.8

 

1. General Info

This project is an attempt to bring the Windows95 Wizard to the Java environment. It is a package. It is not a self runnable application or applet. Instead you have to do some programming yourself in order to display this Wizard.

All these mean that you can use it like every Java AWT component. It is very easy to use and if you know a little bit about Java and even less about AWT you can create any wizard you want.

 

2. Installation Instructions

You have to do some manual work in order to install it an make it usable. Please see readme.txt for more info.

 

3. The Wizard classes

The wizard classes belong to the following package:

panos.awt

 

This package consists of the next classes:

panos.awt.Wizard

panos.awt.browseButton

panos.awt.wizPage

panos.awt.wizImage

 

 

4. How to enter this packages in your application / applet:

To use them you have to import them first:

import panos.awt.*;

Then, you are ready to use all the wizard classes

 

 

6. Wizard class
 

6.1 General Info

This is the main class of the package. Usually you have to work only with this class and it’s methods.

The class is defined as follows:

public class Wizard extends Frame

 

6.2 Constructors

Remember that by creating a Wizard, you create it’s first page too. So if you use next the addPage() method, you will have 2 pages instead of 1.

Wizard (Applet apl)

Create a new Wizard. You should give the parent applet as parameter.

Example

Wizard mywiz = new Wizard (this);

 

Wizard (Applet apl, int xLen, int yLen)

Create a new Wizard. You should give the parent applet, the width and the height of the window as parameter.

Example

 Wizard mywiz = new Wizard (this, 500, 300)

 

6.3 Methods

public void addItem ( int pag, Object obj )

With this method you can attach an object to a specified page. In order to use it first create the object and then pass it as parameter to this method.

The first parameter is the number of the page and the second the object

Remember that although you can call this method with every object, in order to display the object in the wizard it must be one of the supported types:

Remember that the other objects can be still given as parameters, but the wizPage class will not insert them in the page.

The Layout manager for the Wizard Pages is FlowLayout

 

In order to add other objects or to change the Layout manager, look in the getWizPage method.

Example

Choise ch;

. . .

ch = new Choise ();

ch.addItem (”Option 1”);

ch.addItem (”Option 2”);

ch.addItem (”Option 3”);

mywiz.addItem ( 1, ch);

 

public void addPage ()

With this method you can add a page at the end of the current stream of pages.

REMEMBER!!!! the creator of Wizard object already creates a page, so that it will never be an empty Wizard. If you manually call this method, remember that you add the second, third etc. page.

See the constructors too.

Example

wz.addPage();

 

public void addPicture ( String s_pic )

With this method you can add a picture on the left of this wizard. As a parameter you give the (relative or absolute) filename of the image

Example

wz.addPicture ( ”leftpic.gif” );

 

public void addTopSpace (int spac)

With this method you can define a space on the top of this wizard window. If you don’t use it, then the wizard objects will be put right at the top of the Frame. The parameter is the number of pixels to leave blank.

Example

wz.addTopSpace ( 10 );

 

public boolean existsPage ( int pag )

With this method you can check if the given page number exists. As parameter you give the page number you want to check.

Example

if ( wz.existsPage ( 5 ) )

{

. . .

}

 

public wizPage getWizPage (int page)

This method returns a handler for a wizard page. It is a useful method, if you want to call directly the methods of any wizard page (Panel). Without this method you can not get a handler for the wizard pages stored in a wizard.

It is not recommended though to use this method. It is not recommended to use any of the wizPage methods either. But if you want to change the Layout manager, or add objects not supported by wizPage class directly, this is the only way.

Example

wizPage wpage;

Panel pan;

. . .

pan = new Panel();

wpage = getWizPage (3);

wpage.add ( pan );

 

public boolean handleEvent(Event evt)

This is a method just to handle the button events. Usually you don’t need to call this method directly.

When the Cancel or Finish button is clicked the wizard disappears and an event is given to the parent applet. The event has the following data:

target : the parent applet

id : an integer defining the type of event If the Finish button is clicked then it has a value as defined in Wizard.EventId . If Cancel is clicked then it has a value as Wizard.EventId + 1 . For more info see the EventId variable.

arg : this wizard

In the following example it demostrates how to maniputale the event created by the Wizard class.

Example using the event handler in the applet class

if (ev.id == myWiz.EventId & ev.target == this)

{

System.out.println(”Finish clicked.”);

}

else if (ev.id == (myWiz.EventId + 1) & ev.target == this)

{

System.out.println( "Cancel clicked." );

}

public int pages ()

With this method you can get back the number of pages this wizard has.

Example

int no_of_pages = mywiz.pages();

 

public void setFinish ( int page, boolean finish)

With this method you can set the finish button to every page.

By default the finish button is disabled for all the wizard pages except the last one. Sometimes there is a need to finish the wizard earlier. With this method you can set manually which pages you can exit with the finish button. As parameters it gets the page number and a boolean if it should enable or disable the finish button for this page.

Remember that in the last page the finish button is ALWAYS enabled.

Example

mywiz.setFinish ( 3 , true );

 

public void setPages (int hm_pages)

With this method you can set the number of pages for this Wizard.

If you use it for a second time with a greater number of pages as before, you can add pages with this method. It is a quivker method from addPage().

This method sets the ABSOLUTE number of pages. That means if you call mywiz.setPages (5); in your program just after the constructor, you create 5 pages and not 6, as opposed to the addPage method.
 

Example

Wizard mywiz;

. . .

mywiz = new Wizard ();

mywiz.setPages ( 5 ) ;

 

public void show ()

Use this method in order to display the wizard.

Example

mywiz.show();

 

 

7. browseButton class

 

7.1 General Info

This is a class in order to display a browse button in your wizard. A browse button is a button with a TextField attached to it. If you click on the button then a file dialog box appears and waits for you to select a file name. By clicking in the Open button then the contents of the TextField are replaced with the directory and file name of the file choosed.

The class is defined as follows:

public class browseButton extends Button

 

7.2 Constructors

Remember that by creating a browseButton class usually you create a TextField too, except if you give as parameter an already created TextField.

browseButton ()

Create a new browseButton with default parameters.

The button text will be ” Browse... ” . The class will create an internal TextField for you.
 

Example

browseButton brButton = new browseButton ();

 

browseButton ( String str )

Create a new browseButton.

The button text will be as defined in String str . The class will create an internal TextField for you.
 

Example

browseButton brButton = new browseButton (”Click here to find file name”);

 

browseButton ( TextField tf )

Create a new browseButton.

The button text will be ” Browse... ” . The parameter given is the TextField to use in order to display the results.
 

Example

TextField tf;

. . .

tf = new TextField (25);

browseButton brButton = new browseButton ( tf );

 

browseButton ( String str, TextField tf)

Create a new browseButton with given parameters.

The button text will be as defined in String str . The parameter tf is the TextField to use in order to display the results.
 

Example

TextField tf;

. . .

tf = new TextField (25);

browseButton brButton = new browseButton ( ”Click here to browse...”, tf );

 

 

7.3 Methods

public void action (Event ev, Object obj)

This method is used to manipulate the action events caused by the button. Usually you don’t need to use this method.

 

public String getFilename ()

This method is used to get the filename chosen - or (in other words) the text from the TextField.
 

Example

String finame = brButton.getFilename();

 

public TextField getTextField ()

This method is used to get a pointer for the TextFiled used by this browseButton. Usually you don’t need to use this class.
 

Example

TextField tf = brButton.getTextField()

 

public void setFrame ( Frame fr )

Usually in order for this browseButton to display the File dialog, a frame is needed. Although the Wizard is a Frame, it prefers not to link the Filedialog with this Frame. Instead it creates an (invisible) new Frame. Even more, the Dialog displayed is not modal (although the wizard execution is suspended).

With this method you can save space, by defining the FileDialog Frame to an already created Frame, such as the wizard. By this method you make the filedialog modal to this frame.

It is STRONGLY advised to use this method.
 

Example

Wizard myWiz;

browseButton brButton;

. . .

brButton.setFrame( myWiz )

 

 

8. wizPage class
 

8.1 General Info

This is a class in order to display a browse button in your wizard. A browse button is a button with a TextField attached to it. If you click on the button then a file dialog box appears and waits for you to select a file name. By clicking in the Open button then the contents of the TextField are replaced with the directory and file name of the file choosed.

The class is defined as follows:

public class browseButton extends Button

 

8.2 Constructors

Remember that by creating a browseButton class usually you create a TextField too, except if you give as parameter an already created TextField.

browseButton ()

Create a new browseButton with default parameters.

The button text will be ” Browse... ” . The class will create an internal TextField for you.
 

Example

browseButton brButton = new browseButton ();
 

browseButton ( String str )

Create a new browseButton.

The button text will be as defined in String str. The class will create an internal TextField for you.
 

Example

browseButton brButton = new browseButton ( "Click to select file name" );

browseButton ( TextField tf )

Create a new browseButton.

The button text will be ” Browse... ” . The class will use the given TextField .
 

Example

Textfield tf;

. . .

tf = new TextField (25);

browseButton brButton = new browseButton ( tf );
 

browseButton ( STring str, TextField tf)

Create a new browseButton .

The button text will be as defined in String str . The class will use the given TextField .
 

Example

Textfield tf;

. . .

tf = new TextField (25);

browseButton brButton = new browseButton ( "Click here to select file name" , tf );
 
 

8. Other classes
 
Wizard uses two more classes: wizImage and wizPage.
They are defined as follows:

public class wizImage extends Canvas

public class wizPage extends Panel
 

Both classes are for it's internel use and normaly you don't have to call them directly.

Especially for the wizPage you can still get a handler for a specific page and call it directly, as described in the getWizPage(int) method above.
For developers: if you want to create other objects to include in a wizard, please e-mail me to give you more information and the source of the wizPage class, so that you'll have the needed information.
 

THANK YOU FOR DOWNLOADING THIS PACKAGE
 

Panos Katsaloulis

e-mail : teras@writeme.com
 

Back to Top ^