IcanGui
Class GuiTextDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by IcanGui.GuiTextDialog
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class GuiTextDialog
extends java.awt.Dialog
implements java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.FocusListener

Display a dialog and return text entered for further processing.

Since:
1.0;
Version:
1.1.15;
Updated by Louis Handler on Dec 12, 2007, 14:00 EST (1.1.15).
Updated by Louis Handler on Oct 11, 2005, 08:22 EDT (1.1.6).
Updated by Louis Handler on Jul 19, 2005, 07:36 EDT (1.1.5).
Updated by Louis Handler on Mar 28, 2000, 14:00 EST.
Updated by Louis Handler on Mar 13, 2000, 14:13 EST.
Updated by Louis Handler on Feb 22, 2000, 15:21 EST.
Updated by Louis Handler on Oct 27, 1999, 13:50 EDT.
Updated by Louis Handler on Nov 20, 1998, 10:25 EST.
Updated by Louis Handler on Jul 21, 1998, 08:33 EDT.
Updated by Matthew Der on Jun 23, 1998.
Updated by Steve Gnepp on Jun 18, 1998.
Updated by Steve Gnepp on Feb 23, 1998.
Updated by Louis Handler on Jan 27, 1998.
Updated by Steve Gnepp on Jan 27, 1998.
Author:
Louis Handler
See Also:
Dialog, Serialized Form

Nested Class Summary
(package private)  class GuiTextDialog.Madapter
          Mouse Adapter Inner Class
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String[] buttonLabels
          Labels to display on action buttons.
private  java.awt.Button[] buttons
          Action buttons.
private  java.lang.String[] descr
          Description of data to be entered.
private  java.awt.TextField[] entry
          TextField in which to enter data.
private  int focus
          Current focus.
private static int iCancel
          Cancel Button will exit this screen discarding any data entered.
private static int iHelp
          Help Button will display a set of information.
private static int iOk
          OK Button will verify the data.
private static int MAX_ENTRIES
          Maximum number of data items that the user may request.
private static int nButtons
          Number of action buttons.
private  int nEntries
          The number of data items that are requested from the user.
private  java.awt.Color oldColorB
          Background color used to set entry value when valid.
private  int oldFocus
          Previous focus.
private  java.awt.Component saveCompFocus
          Current component.
private  java.awt.Component[] ta
          Textarea or Label for description.
private  java.lang.String[] theText
          Data entered.
private  java.lang.String title
          Title at top of window frame.
private  java.lang.String[] type
          String to contain data type.
private  IcanFrame windowFrameParent
          Parent frame object.
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
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
GuiTextDialog(IcanFrame parent, java.lang.String title, java.lang.String descr, java.lang.String type)
          Constructor creates a File Dialog window with 1 entry field.
GuiTextDialog(IcanFrame parent, java.lang.String title, java.lang.String descr1, java.lang.String type1, java.lang.String descr2, java.lang.String type2)
          Constructor creates a File Dialog window with 2 entry fields.
GuiTextDialog(IcanFrame parent, java.lang.String title, java.lang.String descr1, java.lang.String type1, java.lang.String descr2, java.lang.String type2, java.lang.String descr3, java.lang.String type3)
          Constructor creates a File Dialog window with 3 entry fields.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Perform the appropriate action.
private  void buildLayout(int nEntries)
          Build table for entry fields.
 void flagEntry()
          Reverse video, highlight, and set focus to first entry.
 void flagEntry(int j, java.awt.Color c)
          Reverse video, highlight, and set focus to indexed entry.
 void focusGained(java.awt.event.FocusEvent evt)
          Perform Focus Gained
 void focusLost(java.awt.event.FocusEvent evt)
          Perform Focus Lost
 java.lang.String getName()
          Get class name.
 java.lang.String getTheText()
          Return first string entered.
 java.lang.String getTheText(int j)
          Return string corresponding to index.
private  void helpMe()
          Display help message.
private  void helpMe(java.awt.Component target)
          Display help message.
 void keyPressed(java.awt.event.KeyEvent evt)
          Perform Key Pressed
 void keyReleased(java.awt.event.KeyEvent evt)
          Perform key Release
 void keyTyped(java.awt.event.KeyEvent evt)
          Perform Key Typed
 void remove()
          Dispose of any components required before disposing of parent.
 void setCompFocus()
          Set focus to some component.
 void setCompFocus(java.awt.Component cFocus)
          Set focus in current class/frame.
 void setCompFocus(int j)
          Set focus to entry corresponding to index.
 void setTheText(int j, java.lang.String s)
          Set string entry corresponding to index.
 void setTheText(java.lang.String s)
          Set first string entry.
private  boolean validEntries()
          Test all entries for validity (starting with current entry).
private  boolean validEntry(int j, boolean showMsg)
          Test entry for validity.
 
Methods inherited from class java.awt.Dialog
addNotify, getAccessibleContext, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, 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, getMousePosition, getMouseWheelListeners, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_ENTRIES

private static final int MAX_ENTRIES
Maximum number of data items that the user may request. Used for maximum size of arrays.

See Also:
Constant Field Values

nEntries

private int nEntries
The number of data items that are requested from the user.


focus

private int focus
Current focus.


oldFocus

private int oldFocus
Previous focus.


oldColorB

private java.awt.Color oldColorB
Background color used to set entry value when valid.


windowFrameParent

private IcanFrame windowFrameParent
Parent frame object.


title

private java.lang.String title
Title at top of window frame.


descr

private java.lang.String[] descr
Description of data to be entered.


type

private java.lang.String[] type
String to contain data type. Valid types are "D" for double, "I" for int, "S" for String.


theText

private java.lang.String[] theText
Data entered.


ta

private java.awt.Component[] ta
Textarea or Label for description.


entry

private java.awt.TextField[] entry
TextField in which to enter data.


buttonLabels

private static final java.lang.String[] buttonLabels
Labels to display on action buttons.


nButtons

private static final int nButtons
Number of action buttons.


buttons

private java.awt.Button[] buttons
Action buttons.


iOk

private static final int iOk
OK Button will verify the data.

See Also:
Constant Field Values

iCancel

private static final int iCancel
Cancel Button will exit this screen discarding any data entered.

See Also:
Constant Field Values

iHelp

private static final int iHelp
Help Button will display a set of information.

See Also:
Constant Field Values

saveCompFocus

private java.awt.Component saveCompFocus
Current component.

Constructor Detail

GuiTextDialog

public GuiTextDialog(IcanFrame parent,
                     java.lang.String title,
                     java.lang.String descr,
                     java.lang.String type)
Constructor creates a File Dialog window with 1 entry field.

Parameters:
parent - Parent frame object.
title - Title at top of window frame.
descr - Description of data to be entered.
type - String to contain data type. Valid types are "D" for double, "I" for int, "S" for String.

GuiTextDialog

public GuiTextDialog(IcanFrame parent,
                     java.lang.String title,
                     java.lang.String descr1,
                     java.lang.String type1,
                     java.lang.String descr2,
                     java.lang.String type2)
Constructor creates a File Dialog window with 2 entry fields.

Parameters:
parent - Parent frame object.
title - Title at top of window frame.
descr1 - Description of 1st data field to be entered.
type1 - String to contain 1st data type.
descr2 - Description of 2nd data field to be entered.
type2 - String to contain 2nd data type. Valid types are "D" for double, "I" for int, "S" for String.

GuiTextDialog

public GuiTextDialog(IcanFrame parent,
                     java.lang.String title,
                     java.lang.String descr1,
                     java.lang.String type1,
                     java.lang.String descr2,
                     java.lang.String type2,
                     java.lang.String descr3,
                     java.lang.String type3)
Constructor creates a File Dialog window with 3 entry fields.

Parameters:
parent - Parent frame object.
title - Title at top of window frame.
descr1 - Description of 1st data field to be entered.
type1 - String to contain 1st data type.
descr2 - Description of 2nd data field to be entered.
type2 - String to contain 2nd data type.
descr3 - Description of 3rd data field to be entered.
type3 - String to contain 3rd data type. Valid types are "D" for double, "I" for int, "S" for String.
Method Detail

buildLayout

private void buildLayout(int nEntries)
Build table for entry fields.

Parameters:
nEntries - The number of data items that are requested from the user.

remove

public void remove()
Dispose of any components required before disposing of parent.


getTheText

public java.lang.String getTheText()
Return first string entered.

Returns:
first String entered.

getTheText

public java.lang.String getTheText(int j)
Return string corresponding to index.

Parameters:
j - index
Returns:
index String entered.

setTheText

public void setTheText(java.lang.String s)
Set first string entry.

Parameters:
s - (string) value to set

setTheText

public void setTheText(int j,
                       java.lang.String s)
Set string entry corresponding to index.

Parameters:
j - index
s - (string) value to set

flagEntry

public void flagEntry()
Reverse video, highlight, and set focus to first entry. Background color is set to cyan.


flagEntry

public void flagEntry(int j,
                      java.awt.Color c)
Reverse video, highlight, and set focus to indexed entry.

Parameters:
j - entry index
c - Color

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Perform the appropriate action.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - Action event.

focusGained

public void focusGained(java.awt.event.FocusEvent evt)
Perform Focus Gained

Specified by:
focusGained in interface java.awt.event.FocusListener
Parameters:
evt - FocusEvent

focusLost

public void focusLost(java.awt.event.FocusEvent evt)
Perform Focus Lost

Specified by:
focusLost in interface java.awt.event.FocusListener
Parameters:
evt - FocusEvent

setCompFocus

public void setCompFocus()
Set focus to some component.


setCompFocus

public void setCompFocus(java.awt.Component cFocus)
Set focus in current class/frame.

Parameters:
cFocus - Component to save to reset later.

setCompFocus

public void setCompFocus(int j)
Set focus to entry corresponding to index.

Parameters:
j - entry index

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Perform key Release

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
evt - KeyEvent

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Perform Key Pressed

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
evt - KeyEvent

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Perform Key Typed

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
evt - KeyTyped

validEntries

private boolean validEntries()
Test all entries for validity (starting with current entry). Set the focus to the first invalid entry. Clear any highlighting for all valid entries.

Returns:
True if all entries are valid.

validEntry

private boolean validEntry(int j,
                           boolean showMsg)
Test entry for validity.

Parameters:
j - Entry index.
showMsg - Show err msg if entry invalid.
Returns:
True iff entry is valid.

helpMe

private void helpMe()
Display help message.


helpMe

private void helpMe(java.awt.Component target)
Display help message.

Parameters:
target - Component for which error/help message is displayed.

getName

public java.lang.String getName()
Get class name.

Overrides:
getName in class java.awt.Component
Returns:
Class name.