g-wiz

A Java Swing wizard framework

License

License

GroupId

GroupId

se.gustavkarlsson
ArtifactId

ArtifactId

g-wiz
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

g-wiz
A Java Swing wizard framework
Project URL

Project URL

https://github.com/gustavkarlsson/g-wiz
Source Code Management

Source Code Management

https://github.com/gustavkarlsson/g-wiz

Download g-wiz

How to add to project

<!-- https://jarcasting.com/artifacts/se.gustavkarlsson/g-wiz/ -->
<dependency>
    <groupId>se.gustavkarlsson</groupId>
    <artifactId>g-wiz</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/se.gustavkarlsson/g-wiz/
implementation 'se.gustavkarlsson:g-wiz:1.0.1'
// https://jarcasting.com/artifacts/se.gustavkarlsson/g-wiz/
implementation ("se.gustavkarlsson:g-wiz:1.0.1")
'se.gustavkarlsson:g-wiz:jar:1.0.1'
<dependency org="se.gustavkarlsson" name="g-wiz" rev="1.0.1">
  <artifact name="g-wiz" type="jar" />
</dependency>
@Grapes(
@Grab(group='se.gustavkarlsson', module='g-wiz', version='1.0.1')
)
libraryDependencies += "se.gustavkarlsson" % "g-wiz" % "1.0.1"
[se.gustavkarlsson/g-wiz "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

g-wiz

A Java Swing wizard framework

Introduction

g-wiz is an easy to use wizard framework for Java. I made it to suit my own needs, but it should come in handy for others as well.

Getting started

Getting started with g-wiz is really simple. It can be done in 3 short steps.

  1. Implement a couple of pages by extending AbstractWizardPage.

  2. Initialize the wizard and controller (in this example we use the provided JFrameWizard):

    JFrameWizard wizard = JFrameWizard("My new wizard")
    WizardController controller = new WizardController(wizard);
    
  3. Start the wizard using the controller and a page:

    AbstractWizardPage startPage = new MyStartPage();
    wizard.setVisible(true);
    controller.startWizard(startPage);
    

You can also check out the files in src/demo for a complete example.

Class Descriptions

To use g-wiz, you need to familiarize yourself with 3 classes:

WizardController

Controls wizard behaviour such as maintaining history, handling navigation, starting and restarting the wizard.

Instanciate it with a Wizard argument and then invoke startWizard(AbstractWizardPage) to start the wizard with the specified page.

Wizard

An interface for creating wizards. A wizard can theoretically be any class, but JFrame, JWindow, JPanel and JDialog are strong candidates.

getWizardPageContainer() is a very important method and should return the container (like a JPanel) which will hold the current AbstractWizardPage. This means that the rest of the wizard "wraps" itself around the page container, allowing the implmementer to have complete freedom over the design. The WizardController calls getWizardPageContainer() to add/remove pages to/from it, so great care should be taken when modifying it's content.

The getXyzButton() methods should all return the corresponding navigation button (or null if you don't feel like you need that button).

AbstractWizardPage

Represents a page in the wizard. Implement it as you would a regular JPanel.

The getNextPage() method is used by the WizardController so it knows where pressing "Next" will take the user. It can get called multiple times to check whether there is a "next page" to show, so it's probably not a good idea to create a new "next page" every time it's called.

isCancelAllowed(), isPreviousAllowed(), isNextAllowed(), and isFinishAllowed() controls the navigation buttons (WizardController calls these to enable/disable the buttons) and should be self explanatory.

Structure

This section explains how things like page order and history works.

Page Order

The order of the wizard pages is not determined by the wizard itself or some pre created list; it depends entirely on the pages themself. Every page must implement getNextPage() which should always return the next page in the wizard (null is a valid return value).

Page History

The page history consists of a stack of previously visited pages.

Everytime the user presses "Next", the current page is put on top of the stack and it's getNextPage() is called. The return page is then set as the new "current page". The "Previous" button however, will always take you back to the last page by "popping" the stack and setting that page as the new "current page".

Download

The best way to download g-wiz is with Apache Maven. Just add this to the in your pom.xml:

<dependency>
	<groupId>se.gustavkarlsson</groupId>
	<artifactId>g-wiz</artifactId>
	<version>1.0.1</version>
</dependency>

If you want to download the files manually, you can find jars, sources, and javadoc in the Sonatype OSS Repository.

Versions

Version
1.0.1
1.0.0