Class WizardController


  • public class WizardController
    extends java.lang.Object
    Controllers encapsulate the logic needed to coordinate the various components of a wizard dialog. By using a controller, you do not need to subclass a specific wizard dialog base class. Instead, you can convert any group of appropriate controls to have wizard-like functionality.

    The controller links a group of JButtons, a WizardPanel, and a WizardModel. The buttons are used to control the page turning and finish actions of the panel. The controller will attach appropriate listeners to the buttons and use these to modify the current page in the model or finish the wizard.

    Since:
    3.0
    Author:
    Chris Jennings
    • Constructor Summary

      Constructors 
      Constructor Description
      WizardController​(javax.swing.JButton nextBtn, javax.swing.JButton prevBtn, javax.swing.JButton finishBtn, WizardPanel panel, WizardModel model)
      Creates a new controller that makes a WizardPanel interactive by linking it with a set of controls and a WizardModel.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()
      Removes all listeners installed by the controller and causes it to cease functioning as a controller.
      javax.swing.JButton getFinishButton()
      Returns the button that finishes the wizard.
      WizardModel getModel()
      Returns the model that controls the page logic.
      javax.swing.JButton getNextPageButton()
      Returns the button that advances to the next page.
      WizardPanel getPanel()
      Returns the panel that displays the pages of the wizard.
      javax.swing.JButton getPreviousPageButton()
      Returns the button that goes back to the next page.
      protected void handleFinishButton()
      Called to handle the user pressing the Finish button.
      protected void handleNextPageButton()
      Called to handle the user pressing the Next/Continue button.
      protected void handlePreviousPageButton()
      Called to handle the user pressing the Back/Go Back button.
      protected void install()
      This is called by the constructor to install event handlers on the buttons.
      protected void updateButtonStates()
      Updates the enabled states of the buttons to reflect the current state of the model.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nextBtn

        protected final javax.swing.JButton nextBtn
      • prevBtn

        protected final javax.swing.JButton prevBtn
      • finishBtn

        protected final javax.swing.JButton finishBtn
    • Constructor Detail

      • WizardController

        public WizardController​(javax.swing.JButton nextBtn,
                                javax.swing.JButton prevBtn,
                                javax.swing.JButton finishBtn,
                                WizardPanel panel,
                                WizardModel model)
        Creates a new controller that makes a WizardPanel interactive by linking it with a set of controls and a WizardModel.
        Parameters:
        nextBtn - the button that will advance to the next page
        prevBtn - the button that will go back to the previous page
        finishBtn - the button that will finish the wizard procedure
        panel - the panel that displays pages from the model
        model - the model that controls the page order and fires events
    • Method Detail

      • install

        protected void install()
        This is called by the constructor to install event handlers on the buttons. Subclasses may override this to alter the controller logic.
      • updateButtonStates

        protected void updateButtonStates()
        Updates the enabled states of the buttons to reflect the current state of the model.
      • handleNextPageButton

        protected void handleNextPageButton()
        Called to handle the user pressing the Next/Continue button. Can be overridden to modify controller behaviour.
      • handlePreviousPageButton

        protected void handlePreviousPageButton()
        Called to handle the user pressing the Back/Go Back button. Can be overridden to modify controller behaviour.
      • handleFinishButton

        protected void handleFinishButton()
        Called to handle the user pressing the Finish button. Can be overridden to modify controller behaviour.
      • dispose

        public void dispose()
        Removes all listeners installed by the controller and causes it to cease functioning as a controller. This should be called if you wish to replace this controller with another one.
      • getNextPageButton

        public javax.swing.JButton getNextPageButton()
        Returns the button that advances to the next page.
        Returns:
        the Next button
      • getPreviousPageButton

        public javax.swing.JButton getPreviousPageButton()
        Returns the button that goes back to the next page.
        Returns:
        the Go Back button
      • getFinishButton

        public javax.swing.JButton getFinishButton()
        Returns the button that finishes the wizard.
        Returns:
        the Finish button
      • getPanel

        public WizardPanel getPanel()
        Returns the panel that displays the pages of the wizard.
        Returns:
        the panel linked to the controller
      • getModel

        public WizardModel getModel()
        Returns the model that controls the page logic.
        Returns:
        the model linked to the controller