com.jthomas.mailfaces
Class Prompter

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--com.jthomas.mailfaces.Prompter
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
PromptCheck, PromptLogin

public class Prompter
extends java.awt.Dialog

Prompter.java Object that will prompt the user for some input. This implementation is primarily done to get around a bug in Java 1.0.2 modal Dialogs that does not wait for the User input before continuing. This Object is used as follows to display a message and wait for the user to press OK or Cancel: Prompter p = Prompter.create(); do this only once p.setMsgPrompt("Multiline \n msg"); p.showPrompt(); if (p.getStatus() == Prompter.STATUS_OK) ----- else System.exit(0); This Object is used as follows to display a prompt for input text and wait for the user to press OK or Cancel: Prompter p = Prompter.create(); do this only once p.setTextInputPrompt("Prompt msg","default value","Title line"); p.showPrompt(); if (p.getStatus() == Prompter.STATUS_OK) String result = p.getTextInput(); else System.exit(0); If used from within an action method, then the call to p.getStatus() should be done outside of of the action thread. Uses the MultiLineDialog from David Flanagan "Java in a Netshell"

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static java.awt.Frame _DialogFrame
           
protected static Prompter _Prompter
           
 int _Status
           
 
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
 
Method Summary
static Prompter create()
           
static Prompter create(java.awt.Frame frame, boolean modal)
          create(String Prompt,String default) -> reference to Prompter object This is a Class method that the user of Prompter will invoke to build a Prompter dialog object This method should be invoked only once to build a reuseable Prompter object
 int getStatus()
          getStatus() -> int _Status This is the method that is called by the program using Prompter when it wants the Users input.
 java.lang.String getTextInput()
           
static void main(java.lang.String[] args)
           
 void setMsgPrompt(java.lang.String msg)
          Method to setup a Msg Dialog The message can have multiple lines (using "\n")
 void setTextInputPrompt(java.lang.String prompt, java.lang.String deflt, java.lang.String title)
           
protected  java.awt.Panel setupButtons()
          setup a panel with the OK and Cancel buttons
 void setVisible(boolean show)
          setVisible() -> show or hide the window This is the method that is called by the program using Prompter when it wants the Prompt dialog to be displayed for the user.
 
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, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_DialogFrame

protected static java.awt.Frame _DialogFrame

_Prompter

protected static Prompter _Prompter

_Status

public int _Status
Method Detail

create

public static Prompter create(java.awt.Frame frame,
                              boolean modal)
create(String Prompt,String default) -> reference to Prompter object This is a Class method that the user of Prompter will invoke to build a Prompter dialog object This method should be invoked only once to build a reuseable Prompter object


create

public static Prompter create()

setMsgPrompt

public void setMsgPrompt(java.lang.String msg)
Method to setup a Msg Dialog The message can have multiple lines (using "\n")


setTextInputPrompt

public void setTextInputPrompt(java.lang.String prompt,
                               java.lang.String deflt,
                               java.lang.String title)

setupButtons

protected java.awt.Panel setupButtons()
setup a panel with the OK and Cancel buttons


getTextInput

public java.lang.String getTextInput()

setVisible

public void setVisible(boolean show)
setVisible() -> show or hide the window This is the method that is called by the program using Prompter when it wants the Prompt dialog to be displayed for the user. At the time it is called, everything is ready, it just needs to be displayed

Overrides:
setVisible in class java.awt.Component

getStatus

public int getStatus()
getStatus() -> int _Status This is the method that is called by the program using Prompter when it wants the Users input. This will poll for the _Status flag to be set. The polling loop contains a 1 second sleep. Because of the sleep, we cannot invoke this dialog out of an Event thread because would hang if the event thread goes to sleep


main

public static void main(java.lang.String[] args)