Class WizardPane
- All Implemented Interfaces:
WizardCompletionTester
,ActionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,ChangeListener
,DocumentListener
,ListSelectionListener
,TableModelListener
,TreeSelectionListener
A WizardPane is simply a container (JPanel) having additional methods that support convenient addition of input fields, check boxes, file choosers, number spinners, etc. These input methods are pre-connected with a set of event handlers. When a value is changed in the user interface, the event handlers will perform error checking and set the value in the Wizard dictionary.
Each input field is associated with a variable label. The varaible label is the key that is used to retrieve the value from the dictionary.
Here are some of the controls that are supported by the WizardPane
Method | Purpose | Implemented by |
---|---|---|
addLabel | Add a centered label | JLabel |
addSpace | Add white space between elements | Box |
addText | Add a text input field, surrounded by a bordered frame | JTextField |
addTextArea | Add a text input area, surrounded by a bordered frame | JTextArea |
addBoolean | Add a checkbox | JCheckBox |
addInteger | Add a number spinner for integers | JSpinner |
addDouble | Add a number spinner for doubles | JSpinner |
addComboBox | Add a ComboBox type of widget to select a single item from a list | JComboBox |
addListBox | Add a List type of widget to select multiple items from a list | JList |
addExpression | Add a combination of text entry and query builder | QueryBuilder |
addFile | Add a file selector, including a file selection dialog | JFileChooser |
addCoverage | Add a coverage selector, including a coverage selection dialog | JFileChooser |
addPanel | Add a bordered frame, and within it a nested WizardPane | WizardPane |
addOption | Add a checkbox and a nested WizardPane. The checkbox controls if the nested pane is enabled or disabled. | WizardPane |
addTabbedPane | Add a tabbed pane. WizardPane objects are used to implement each tab. | WizardTabbedPane |
addProgressBar | Add a progress bar. | JProgressBar |
addTree | Add a tree widget. | PathTree |
addButton | Add a button. | JButton |
addToggleButton | Add a toggle button. | JToggleButton |
addExclusiveOption | Add a group of radio buttons that provide a set of mutally exclusive options. | JRadioButton |
addTable | Add a simple table widget. | JTable |
addColor | Add a color chooser. | JColorChooser |
WizardPane panels are usually used as a sequence of 'steps' in
in a wizard. The flow of control is handled by the Wizard
object that contains the WizardPanes. The order of the steps is
defined by chaining one WizardPane to the next. The first WizardPane
in the sequence is obtained from the Wizard
object, using the
Wizard.getFirstStep()
method. Subsequent steps in the
sequence are generated by successively using the addNextStep()
method in each WizardPane in the chain.
The sequence of steps in a Wizard is usually linear. Forks in the
sequence can be generated using the addExclusiveOption(java.lang.String, java.lang.String)
method.
A WizardPane object can be embedded inside another WizardPane. This is convenient to allow enabling and disabling of groups of components.
- See Also:
Wizard
, Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
static int
static int
static int
static Icon
static Icon
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorsConstructorDescriptionWizardPane(Wizard wiz)
Construct a new WizardPane opbject, specifying the parent wizard that contains the dictionary and controls the flow of steps. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBoolean(String label, String var, boolean def)
Add a checkbox for booleansAdd a button.A color selector widget.addComboBox(String label, String var, Object init, Object[] def)
Add a ComboBox type of widget to select items from a list.void
addCoverage(String label, String var, Object def)
Add a coverage selection entryvoid
addCoverage(String label, String var, Object def, int type)
Add a number spinner for doubles.addExclusiveOption(String label, String group)
Add a set of radio buttons to display mutally exclusive options.addExpression(String label, String var, String def, AttributeStore as)
Add an expression input field, with a query builder buttonAdd a file selection entryvoid
Add an HTML edit area, surrounded by a bordered frame.addInteger(String label, String var, int init, int low, int high, int step)
Add a number spinner for integersAdd a display label to the pane.addListBox(String label, String var, Object[] init, Object[] def)
Add a ListBox type of widget to select items from a list.Add a 'next' step to follow the current step.addOpenTable(String label, String var, AttributeStore def, Class type)
Add a sub-pane, with a check box that enables and disables the embedded controls.Add a sub-pane, with a check box that enables and disables the embedded controls.Add a sub-panel, with an optional titled border.Add a progress bar widget.void
addSpace()
Add some space between entries.Add a Tabbed panel to the container.addTable(String label, String var, TableModel model, boolean addRows)
Add a table widget to the panel.addTable(String label, String var, TableModel model, boolean addRows, boolean upDown)
Add a text input field, surrounded by a bordered frame.addTextArea(String label, String var, String init)
Add a text input area, surrounded by a bordered frame.addToggleButton(String label)
Add a toggle button.Add a tree widget.void
getHelp()
Get information about the custom help topic set for this pane.getIcon()
getNext()
Get a reference to the next step.getPrev()
Get a reference to the preceeding step.Get the Wizard object for this itemboolean
hasNext()
Test if there is a following step.boolean
hasPrev()
Test if there is a preceeding step.void
boolean
isComplete(Wizard wiz)
void
void
Set the completion tester for this panevoid
setEnabled(boolean state)
Enable or disable the components on this panevoid
Set the custom help associated with this WizardPane.void
void
Set an action to perform when entering or leaving this panesetNextStep(WizardPane step)
Set a 'next' step to follow the current step.void
setPrev(WizardPane prev)
void
void
static JTable
tableWithControls(JPanel jp, TableModel model, boolean addRows, boolean upDown, boolean isEnabled)
boolean
test()
Test the value of top-most pane.static void
updateTableListeners(AbstractTableModel oldModel, AbstractTableModel newModel)
Update the listeners when a table model is replaced in table widget.void
void
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
FILE_OPEN
public static final int FILE_OPEN- See Also:
- Constant Field Values
-
FILE_SAVE
public static final int FILE_SAVE- See Also:
- Constant Field Values
-
DIRECTORY_OPEN
public static final int DIRECTORY_OPEN- See Also:
- Constant Field Values
-
DIRECTORY_SAVE
public static final int DIRECTORY_SAVE- See Also:
- Constant Field Values
-
openIcon
-
queryIcon
-
-
Constructor Details
-
WizardPane
Construct a new WizardPane opbject, specifying the parent wizard that contains the dictionary and controls the flow of steps.- Parameters:
wiz
- the parent Wizard
-
-
Method Details
-
isComplete
- Specified by:
isComplete
in interfaceWizardCompletionTester
-
setIcon
-
getIcon
-
addLabel
Add a display label to the pane. The display text can be HTML and will be centered in the display area.- Parameters:
text
- The text to display- Returns:
- The JLabel component the implements the display
-
addText
Add a text input field, surrounded by a bordered frame.- Parameters:
label
- A label to be displayed in the bordered framevar
- The dictionary key associated with the result.init
- The initial value to be placed in the field.
-
addTextArea
Add a text input area, surrounded by a bordered frame.- Parameters:
label
- A label to be displayed in the bordered frame. If the label is null then no border is added.var
- The dictionary key associated with the result.init
- The initial value to be placed in the field.
-
addHTML
Add an HTML edit area, surrounded by a bordered frame.- Parameters:
label
- A label to be displayed in the bordered frame. If the label is null then no border is added.var
- The dictionary key associated with the editor.rw
- A reference to theReportWriter
object that will be the container for the associated report, or null if this wizard is not being used for a report.folder
- the folder that the report will be placed in to, or null if this wizard is not being used for a report.init
- The initial value to be placed in the editor.
-
addBoolean
Add a checkbox for booleans- Parameters:
label
- A label to be displayed to the left of the checkboxvar
- The dictionary key associated with the result.def
- The initial value to be placed in the field.- Returns:
- A reference to the JCheckBox object
-
addInteger
Add a number spinner for integers- Parameters:
label
- A label to be displayed to the left of the spinnervar
- The dictionary key associated with the result.init
- The initial value to be placed in the field.low
- The lower range for the spinnerhigh
- The upper range for the spinnerstep
- The step size for the spinner- Returns:
- A reference to the JSpinner object
-
addDouble
public JSpinner addDouble(String label, String var, double init, double low, double high, double step)Add a number spinner for doubles.- Parameters:
label
- A label to be displayed to the left of the spinnervar
- The dictionary key associated with the result.init
- The initial value to be placed in the field.low
- The lower range for the spinnerhigh
- The upper range for the spinnerstep
- The step size for the spinner- Returns:
- A reference to the JSpinner object
-
addComboBox
Add a ComboBox type of widget to select items from a list.- Parameters:
label
- A label to be displayed to the left of the ComboBoxvar
- The dictionary key associated with the result.init
- The initial selected value to be placed in the field.def
- A list of objects that will be displayed in the ComboBox- Returns:
- A reference to the JComboBox object
-
addListBox
Add a ListBox type of widget to select items from a list. The default ListBox supports multiple selections. If you want singel selections then- set the JList selection mode to ListSelectionModel.SINGLE_SELECTION
- set the item in the dictionary to the correct value (by default it will contain an array).
Object[] stores = new Object[] {"a", "b", "c"}; JList jl = wp.addListBox("Select", "table", new Object[] {"a"}, stores); jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); wiz.putItem("table", "a");
- Parameters:
label
- A label to be displayed in a border surrounding the list.var
- The dictionary key associated with the result.init
- The initially values to be selected in the list.def
- The initial list of objects- Returns:
- A reference to the JList object
-
addExpression
Add an expression input field, with a query builder button- Parameters:
label
- A label to be displayed in a border surrounding the input field.var
- The dictionary key associated with the result.def
- The initial expression.as
- An AttributeStore object that the expression will be compiled against.- Returns:
- A reference to the JTextField object that will contain the expression string.
-
addFile
Add a file selection entry- Parameters:
label
- A label to be displayed in a border surrounding the input field.var
- The dictionary key associated with the result.def
- The initial file value.type
- A constant value indicating the type of file open operation. The value should be one ofFILE_OPEN
,FILE_SAVE
,DIRECTORY_OPEN
, orDIRECTORY_SAVE
.- Returns:
- A reference to the file selection control. You can use the control to add filters and other custom file selection behaviour.
-
addCoverage
Add a coverage selection entry- Parameters:
label
- A label to be displayed in a border surrounding the input field.var
- The dictionary key associated with the result.def
- The initial coverage value.
-
addCoverage
-
addOpenTable
-
addSpace
public void addSpace()Add some space between entries. This space is implemented usingBox.createVerticalGlue()
, so it will expand to consume any leftover space in the panel. -
addOption
Add a sub-pane, with a check box that enables and disables the embedded controls. When you add this control you will receive a reference to another WizardPane. You can add more controls to that sub-pane. When the checkbox is check all controls in the sub-pane are enabled. When the checkbox is unchecked then all controls in the sub-pane become disabled.- Parameters:
label
- A label to be displayed in a border surrounding the sub-pane. If the label starts with a | character then the panel will be surrounded with a border.var
- The dictionary key associated with whether the sub-pane is enabled or disabled.def
- The initial value of the checkbox.- Returns:
- A reference to a Wizardpane object, that can then be filled with other controls.
-
addOption
Add a sub-pane, with a check box that enables and disables the embedded controls. When you add this control you will receive a reference to another WizardPane. You can add more controls to that sub-pane. When the checkbox is check all controls in the sub-pane are enabled. When the checkbox is unchecked then all controls in the sub-pane become disabled.- Parameters:
label
- A label to be displayed in a border surrounding the sub-pane. If the label starts with a | character then the panel will be surrounded with a border.var
- The dictionary key associated with whether the sub-pane is enabled or disabled.def
- The initial value of the checkbox.expand
- A boolean to indicate if the panel should expand to take all extra space.- Returns:
- A reference to a Wizardpane object, that can then be filled with other controls.
-
addPanel
Add a sub-panel, with an optional titled border. This is used for grouping.- Parameters:
label
- A label to be displayed in a border surrounding the sub-pane.expand
- Controls if the sub-panel should be expanded to consume all left-over space in the parent pane.- Returns:
- A WizardPane object that can then be filled with additional controls.
-
addTabbedPane
Add a Tabbed panel to the container. Use the returned WizardTabbedPane object to set up the tabs to be displayed. -
addProgressBar
Add a progress bar widget. -
addTree
Add a tree widget. This Object does not create a variable, but puts up a control that can be used to manipulate the PathTree structure.- Parameters:
label
- A label to be displayed in a border surrounding the tree widget.var
- A dictionary key, not currently associated with anything.model
- A data model to be used with the Tree.single
- A flag to indicate if single or musltiple selections are allowed
-
addButton
Add a button. There are no default actions on the button.- Parameters:
label
- A label to be displayed to the left of the button.- Returns:
- A reference to the JButton object.
-
addToggleButton
Add a toggle button. There are no default actions on the button.- Parameters:
label
- A label to be displayed to the left of the button.- Returns:
- A reference to the JButton object.
-
addNextStep
Add a 'next' step to follow the current step.- Returns:
- A reference to the WizardPane object that will be chained to the current step.
-
setNextStep
Set a 'next' step to follow the current step. Any existing next step will be forgotten.- Parameters:
step
- The step that should override the currently established following step.- Returns:
- The new following step.
-
setPrev
-
addExclusiveOption
Add a set of radio buttons to display mutally exclusive options. The wizard dictionary will contain a string item with a key of "_EXCLUSIVE_"+group that will hold the label of the currently selected fork.- Parameters:
label
- A label to be displayed to the right of the radio button.group
- The name of the group object.- Returns:
- The JRadioButton object.
-
addTable
Add a table widget to the panel. The resulting table will have edit controls if the TableModel is an instance of EditableTableModel.- Parameters:
label
- A label to be displayed in a border surrounding the table widget.var
- A dictionary key, not currently associated with anything.model
- A data model to be used with the JTable. If theTableModel
implements theEditableTableModel
interface then the widget will display editing controls.addRows
- Indicate if controls for adding rows should be added to the widget. This only works if the TableModel object implements theEditableTableModel
interface.- Returns:
- The JTable widget that displays records from the TableModel.
-
addTable
public JTable addTable(String label, String var, TableModel model, boolean addRows, boolean upDown) -
tableWithControls
public static JTable tableWithControls(JPanel jp, TableModel model, boolean addRows, boolean upDown, boolean isEnabled) -
addColor
A color selector widget. -
hasNext
public boolean hasNext()Test if there is a following step. This returns false if this is the last step in the sequence. -
getNext
Get a reference to the next step. -
getLastStep
-
hasPrev
public boolean hasPrev()Test if there is a preceeding step. This returns false if this is the last step in the sequence. -
getPrev
Get a reference to the preceeding step. -
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
stateChanged
- Specified by:
stateChanged
in interfaceChangeListener
-
valueChanged
- Specified by:
valueChanged
in interfaceListSelectionListener
-
valueChanged
- Specified by:
valueChanged
in interfaceTreeSelectionListener
-
insertUpdate
- Specified by:
insertUpdate
in interfaceDocumentListener
-
removeUpdate
- Specified by:
removeUpdate
in interfaceDocumentListener
-
changedUpdate
- Specified by:
changedUpdate
in interfaceDocumentListener
-
tableChanged
- Specified by:
tableChanged
in interfaceTableModelListener
-
updateTableListeners
Update the listeners when a table model is replaced in table widget.- Parameters:
oldModel
- The old model that should be removednewModel
- The new model that should be added
-
setEnabled
public void setEnabled(boolean state)Enable or disable the components on this pane- Overrides:
setEnabled
in classJComponent
- Parameters:
state
- The new state of the components
-
setCompletionTest
Set the completion tester for this pane- Parameters:
vt
- The tester to use to determine if the values entered in this pane are valid.
-
getWizard
Get the Wizard object for this item- Returns:
- A reference to the Wizard object
-
test
public boolean test()Test the value of top-most pane. This implies that completion testers are not allowed on Panel or Option sub-panes. (TabbedPanes are OK because they are not sub-panes).- Returns:
- true if the test succeeds
-
setHelp
Set the custom help associated with this WizardPane. The custom help will be available only on this pane. Note that this help reference is not dynamic. You must set the help before the pane is shown. If you change the help while the pane is being shown the status of the button will not change.- Parameters:
topic
- The help topic to display
-
getHelp
Get information about the custom help topic set for this pane.- Returns:
- a custom help string
-