CSLib
Class InputBox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--CSLib.ClosableDialog
                                |
                                +--CSLib.InputBox

public class InputBox
extends ClosableDialog
implements ActionListener

InputBox is a closable dialog box that can receive and
translate textual keyword input into various Java types. It can read
and convert integers, doubles, strings, and characters.


The user must enter characters into a TextField, and then click on
the "Ok" button. If the characters are inappropriate for the
particular read that has been requested (for example,
if a letter is entered during a call to readInt),
then an ErrorBox is raised.


End-of-input is indicated by the user entering nothing into the
TextField, and then clicking on the "Ok" button.

Author:
M. Dennis Mickunas

Fields inherited from class java.awt.Component
TOP_ALIGNMENT, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT

Constructor Summary
InputBox()
          Constructs an InputBox with a default title.
InputBox(String title)
          Constructs an InputBox with a specific title.

Method Summary
 voidactionPerformed(ActionEvent e)
          Catches the clicking of the OK button (presumably after text has
been entered in the textfield.
 booleaneoi()
          Returns the end-of-input status
 charreadChar()
          Reads an Ascii character, and converts it to an char.
 doublereadDouble()
          Reads an Ascii real number, and converts it to a double.
 intreadInt()
          Reads an Ascii integer, and converts it to an int.
 StringreadString()
          Reads an Ascii string.
 voidsetPrompt(String text)
          Sets the prompt to a particular string.

Methods inherited from class java.awt.Dialog
addNotify, isModal, setModal, getTitle, setTitle, show, hide, dispose, isResizable, setResizable, getAccessibleContext

Methods inherited from class java.awt.Window
pack, toFront, toBack, getToolkit, getWarningString, getLocale, getInputContext, setCursor, getOwner, getOwnedWindows, addWindowListener, removeWindowListener, getListeners, getFocusOwner, postEvent, isShowing, applyResourceBundle, applyResourceBundle, getGraphicsConfiguration

Methods inherited from class java.awt.Container
getComponentCount, countComponents, getComponent, getComponents, getInsets, insets, add, add, add, add, add, remove, remove, removeAll, getLayout, setLayout, doLayout, layout, invalidate, validate, setFont, getPreferredSize, preferredSize, getMinimumSize, minimumSize, getMaximumSize, getAlignmentX, getAlignmentY, paint, update, print, paintComponents, printComponents, addContainerListener, removeContainerListener, deliverEvent, getComponentAt, locate, getComponentAt, findComponentAt, findComponentAt, removeNotify, isAncestorOf, list, list

Methods inherited from class java.awt.Component
getName, setName, getParent, getPeer, setDropTarget, getDropTarget, getTreeLock, isValid, isDisplayable, isVisible, isEnabled, setEnabled, enable, enable, disable, isDoubleBuffered, enableInputMethods, setVisible, show, getForeground, setForeground, getBackground, setBackground, getFont, setLocale, getColorModel, getLocation, getLocationOnScreen, location, setLocation, move, setLocation, getSize, size, setSize, resize, setSize, resize, getBounds, bounds, setBounds, reshape, setBounds, getX, getY, getWidth, getHeight, getBounds, getSize, getLocation, isOpaque, isLightweight, getGraphics, getFontMetrics, getCursor, paintAll, repaint, repaint, repaint, repaint, printAll, imageUpdate, createImage, createImage, prepareImage, prepareImage, checkImage, checkImage, contains, inside, contains, dispatchEvent, addComponentListener, removeComponentListener, addFocusListener, removeFocusListener, addHierarchyListener, removeHierarchyListener, addHierarchyBoundsListener, removeHierarchyBoundsListener, addKeyListener, removeKeyListener, addMouseListener, removeMouseListener, addMouseMotionListener, removeMouseMotionListener, addInputMethodListener, removeInputMethodListener, getInputMethodRequests, handleEvent, mouseDown, mouseDrag, mouseUp, mouseMove, mouseEnter, mouseExit, keyDown, keyUp, action, gotFocus, lostFocus, isFocusTraversable, requestFocus, transferFocus, nextFocus, hasFocus, add, remove, toString, list, list, list, addPropertyChangeListener, removePropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, setComponentOrientation, getComponentOrientation

Methods inherited from class java.lang.Object
getClass, hashCode, equals, notify, notifyAll, wait, wait, wait

Constructor Detail

InputBox

public InputBox()
Constructs an InputBox with a default title.

InputBox

public InputBox(String title)
Constructs an InputBox with a specific title.
Parameters:
title the String to use as the title
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)
Catches the clicking of the OK button (presumably after text has
been entered in the textfield.
Parameters:
e the specific ActionEvent that occurred.

eoi

public boolean eoi()
Returns the end-of-input status
Returns: true if end-of-input is true
See Also:
eoi

readChar

public char readChar()
Reads an Ascii character, and converts it to an char.
End-of-input is indicated by clicking OK without entering anything.
Returns: the char value read.
See Also:
eoi

readDouble

public double readDouble()
Reads an Ascii real number, and converts it to a double.
Raise an ErrorBox if a non-real number is entered.
End-of-input is indicated by clicking OK without entering anything.
Returns: the double value read.
See Also:
eoi

readInt

public int readInt()
Reads an Ascii integer, and converts it to an int.
Raise an ErrorBox if a non-integer is entered.
End-of-input is indicated by clicking OK without entering anything.
Returns: the int value read.
See Also:
eoi

readString

public String readString()
Reads an Ascii string.
End-of-input is indicated by clicking OK without entering anything.
Returns: the String value read.

setPrompt

public void setPrompt(String text)
Sets the prompt to a particular string.
Parameters:
text the specific String to use for the new prompt

Association Links

to Class java.awt.TextField

to Class java.awt.Label

to Class java.awt.Button

to Class java.awt.Font