org.freehep.swing.wizard
Class WizardPage
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--org.freehep.swing.wizard.WizardPage
- All Implemented Interfaces:
- Accessible, EventListener, ImageObserver, KeyListener, MenuContainer, Serializable
- public abstract class WizardPage
- extends JPanel
- implements KeyListener
Extend this class to create a page for the WizardDialog. Implement the
interface HasNextPages if you want there to be pages following this
page, and implement the Finishable interface if you want this to be
the page. You may implement one or both, but implementing
neither would be silly because then neither the "Next" nor "Finish"
button will enable and your page will be a "dead end". Implement
HasHelpPage if you want your page to link to a help topic. Override
the methods getNextEnabled()
and getFinishEnabled()
to control how the "Next" and "Finish" buttons enable.
This class is a KeyListener and has implemented the interface
with non-methods. If you do not override these
methods, doEnable()
will be called when a key
is released on components registered as KeyListeners.
This implementation is designed for when the buttons
enable when text is added to them. For example, if you page had
m_text = new JASTextField();
text.addKeyListener(this);
then the "Next" and "Finish" buttons would enable each time a key is released
in the field text
. You might define getNextEnabled()
as follows:
protected boolean getNextEnabled()
{
String s = m_text.getText();
return s != null && s.length() > 0;
}
- Author:
- Jonas Gifford
- See Also:
WizardDialog
,
HasNextPages
,
Finishable
,
HasHelpPage
,
Serialized Form
Method Summary |
void |
beforeShowing()
This method is called just before the page is brought to the screen. |
protected void |
dispose()
Call to dispose the wizard (i.e., to have it close). |
void |
doBusy(Runnable run)
|
protected void |
doEnable()
Forces the wizard to call getNextEnabled() and getFinishEnabled() to enable the
buttons on the wizard. |
protected boolean |
getFinishEnabled()
Override to provide customized behaviour for enabling the "Finish" button. |
protected boolean |
getNextEnabled()
Override to provide customized behaviour for enabling the "Next" button. |
protected void |
handleError(String message,
Throwable t)
|
void |
keyPressed(KeyEvent e)
Override this to provide your own behaviour for key events; does nothing by default. |
void |
keyReleased(KeyEvent e)
If you add this class as a KeyListener and don't override this method then
the buttons will be enabled on every key event in the definition for this method. |
void |
keyTyped(KeyEvent e)
Override this to provide your own behaviour for key events; does nothing by default. |
void |
onCancel()
This method is called if the user has canceled the wizard. |
protected void |
setNextEnabled(boolean enabled)
|
String |
toString()
This method is public as an implementation side effect; do not call. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle |
WizardPage
public WizardPage(LayoutManager lm)
- Supply a layout manager for the panel to use. See Sun's notes on
using
layout managers. In the constructor of your subclass, add components
to the page as you would add components to a regular container, using the
add(..)
methods. It is not a good idea to use AWT components
here because those heavy-weight components do not mix well with swing's
light-weight components. You should use only
swing components.
The jas.util package has a number of
utility
components that may be useful for these pages.
- Parameters:
lm
- the layout manager to use for this page.- See Also:
LayoutManager
WizardPage
public WizardPage()
beforeShowing
public void beforeShowing()
- This method is called just before the page is brought to the screen. By default, it
does nothing but you can override it to do some last-minute setup on your page.
doBusy
public void doBusy(Runnable run)
keyPressed
public void keyPressed(KeyEvent e)
- Override this to provide your own behaviour for key events; does nothing by default.
- Specified by:
keyPressed
in interface KeyListener
keyReleased
public void keyReleased(KeyEvent e)
- If you add this class as a KeyListener and don't override this method then
the buttons will be enabled on every key event in the definition for this method.
- Specified by:
keyReleased
in interface KeyListener
keyTyped
public void keyTyped(KeyEvent e)
- Override this to provide your own behaviour for key events; does nothing by default.
- Specified by:
keyTyped
in interface KeyListener
onCancel
public void onCancel()
- This method is called if the user has canceled the wizard. By default it does nothing,
but you can override it to perform cleanup if necessary. The wizard follows a preorder
tree traversal, so the
onCancel()
methods are called starting from the bottom
and working up each branch separately to the root.
toString
public String toString()
- This method is public as an implementation side effect; do not call.
- Overrides:
toString
in class Component
getFinishEnabled
protected boolean getFinishEnabled()
- Override to provide customized behaviour for enabling the "Finish" button. By
default, this method returns whether the page implements Finishable. If
your page does not implement that interface, the "Finish" button will never
enable. Call
doEnable()
to call this method, or add your
page as a key listener to a component, and then doEnable()
will
be called each time a key is released in that component.
- Returns:
- whether to enable the "Finish" button
- See Also:
WizardDialog#doEnable()
,
Finishable
getNextEnabled
protected boolean getNextEnabled()
- Override to provide customized behaviour for enabling the "Next" button. By
default, this method returns whether the page implements HasNextPages. If
your page does not implement that interface, the "Next" button will never
enable. Call
doEnable()
to call this method, or add your
page as a key listener to a component, and then doEnable()
will
be called each time a key is released in that component.
- Returns:
- whether to enable the "Next" button
- See Also:
WizardDialog#doEnable()
,
HasNextPages
setNextEnabled
protected void setNextEnabled(boolean enabled)
dispose
protected void dispose()
- Call to dispose the wizard (i.e., to have it close).
doEnable
protected void doEnable()
- Forces the wizard to call
getNextEnabled()
and getFinishEnabled()
to enable the
buttons on the wizard. This method is called by the keyReleased(KeyEvent)
method
if you add this class as a KeyListener to a text field.
- See Also:
WizardDialog#getNextEnabled()
,
WizardDialog#getFinishEnabled()
,
WizardDialog#keyReleased(KeyEvent)
,
KeyEvent
,
KeyListener
handleError
protected void handleError(String message,
Throwable t)
Copyright © 2000-2003 FreeHEP, All Rights Reserved.