kirk.gui.dialog
Class InputDialog

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended bykirk.gui.dialog.PopupDialog
                      extended bykirk.gui.dialog.InputDialog
All Implemented Interfaces:
Accessible, ActionListener, EventListener, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
SingleInputDialog

public abstract class InputDialog
extends PopupDialog

An extension of PopupDialog that asks the user for input. This class is abstract, the actual input is asked by subclasses. The method actionPerformed assumes there is an "OK" button, or a "Cancel" button. In case of the "OK" button, it calls the retrieve method in the Retriever given on construction time. This method should then retrieve any data wanted, and return. This class will then close itself if true was returned by retrieve. If the action command specified by ActionEvent.getActionCommand() is "Cancel" (case insensitive), then the PopupDialog will be closed without calling the retrieve method. In all other cases of action command, this class assumes an "OK" button.
The implementation of actionPerformed in this class allows for subclasses that only define a specific look for the input window, and that have methods and/or attributes that can be used/retrieved by the retrieve method. All buttons that they have should act like "OK" or "Cancel" buttons (see above). If all these requirements have been met, the subclass doesn't have to override actionPerformed. If it needs more buttons (say "Clear") you need to override actionPerformed. You can then define your own button usage, and use super to activate the "OK" and "Cancel" buttons through this class. Note that this will make all buttons that aren't caught using action commands will default to "OK".

If you close an InputDialog with the close button inherent to a Window, closing is done through a standard WindowCloser. This means that this button has the same effect as a "Cancel" button. This means retrieve will not be called. This behaviour is by design, always providing a means to cancel.

Version:
1
Author:
Berend "Kirk" Wouda
See Also:
Retriever, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  Retriever retriever
          The Retriever.
 
Fields inherited from class java.awt.Dialog
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
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
InputDialog(Frame owner, Retriever retriever, int width, int height)
          Constructs a new InputDialog with the passed settings.
 
Method Summary
 void actionPerformed(ActionEvent event)
          This method gets called when an ActionEvent is generated.
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getAccessibleContext, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

retriever

private Retriever retriever
The Retriever.

Constructor Detail

InputDialog

public InputDialog(Frame owner,
                   Retriever retriever,
                   int width,
                   int height)
Constructs a new InputDialog with the passed settings.

Parameters:
owner - The pwning Frame.
retriever - The Retriever that retrieves the values from this object.
width - The width of this Dialog in pixels.
height - The height of this Dialog in pixels.
Method Detail

actionPerformed

public void actionPerformed(ActionEvent event)
This method gets called when an ActionEvent is generated. By default, this object assumes this is caused by an OK button. So, it makes the Retriever retrieve the values it requires, and it then calls the super method of PopupDialog, which closes this Dialog. However, if the action command of the button is "Cancel" (which is case insensitive), the Dialog will be closed as if the close button was pressed. The Retriever will not be called. Subclasses of this class should supercall this method when requiring this functionality.

Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class PopupDialog
Parameters:
event - The standard passed ActionEvent.
See Also:
PopupDialog.actionPerformed(java.awt.event.ActionEvent)