uk.ac.ed.ph.sciprog
Class Input

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by uk.ac.ed.ph.sciprog.Input
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Input
extends javax.swing.JPanel

Input class for producting input field with prompts and reading String, Boolean, int (s), double (s) and options. Scientific Programming Teaching interface.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
Input(java.lang.String prompt, boolean defaultBoolean)
          Constuctor to deal with Boolean input via a JComboBox
Input(java.lang.String prompt, double defaultDouble)
          Constructor to setup input field to read a single double
Input(java.lang.String prompt, double[] defaultDoubles)
          Constructor to setup input field to read multiple doubles
Input(java.lang.String prompt, int defaultInt)
          Constructor to setup input field to read a single integer
Input(java.lang.String prompt, int[] defaultInts)
          Constructor to setup input field to read multiple ints
Input(java.lang.String prompt, java.lang.String defaultInput)
          Constructor to setup input field to read a single String
Input(java.lang.String prompt, java.lang.String[] options, int defaultOption)
          Constructor to give a pop-down box with an String array of options.
 
Method Summary
 boolean getBoolean()
          Get a boolean from the checkbox input.
 double getDouble()
          Get a double from the first input field
 double getDouble(int field)
          Get a double from a specified input field
 double[] getDoubleArray()
          Get a double array from the input fields
 int getInt()
          Get an integer from the first input field
 int getInt(int field)
          Get an integer from a specified input field
 int[] getIntArray()
          Get a int array from the input fields
 int getSelectedIndex()
          Get the selected Index option from a pop-down ComboBox option list.
 java.lang.String getSelectedItem()
          Get the selected item as a String from a pop-down ComboBox option list.
 java.lang.String getString()
          Get a String from the first field.
 java.lang.String getString(int field)
          Get a String from a specified input field
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Input

public Input(java.lang.String prompt,
             java.lang.String defaultInput)
Constructor to setup input field to read a single String

Parameters:
prompt - The prompt that appears on the input panel
defaultInput - The default appearing in the panel

Input

public Input(java.lang.String prompt,
             int defaultInt)
Constructor to setup input field to read a single integer

Parameters:
prompt - The prompt that appears on the input panel
defaultInt - The default appearing in the panel

Input

public Input(java.lang.String prompt,
             double defaultDouble)
Constructor to setup input field to read a single double

Parameters:
prompt - The prompt that appears on the input panel
defaultDouble - The default appearing in the panel

Input

public Input(java.lang.String prompt,
             int[] defaultInts)
Constructor to setup input field to read multiple ints

Parameters:
prompt - The prompt that appears on the input panel
defaultInts - The default appearing in the panel. length of array determines the number of input fields.

Input

public Input(java.lang.String prompt,
             double[] defaultDoubles)
Constructor to setup input field to read multiple doubles

Parameters:
prompt - The prompt that appears on the input panel
defaultDoubles - The default appearing in the panel. length of array determines the number of input fields.

Input

public Input(java.lang.String prompt,
             java.lang.String[] options,
             int defaultOption)
Constructor to give a pop-down box with an String array of options.

Parameters:
prompt - The prompt
options - array of options
defaultOption - selected default option.

Input

public Input(java.lang.String prompt,
             boolean defaultBoolean)
Constuctor to deal with Boolean input via a JComboBox

Parameters:
prompt - The prompt string.
defaultBoolean - Initial state of button
Method Detail

getString

public java.lang.String getString(int field)
Get a String from a specified input field

Parameters:
field - The input field.
Returns:
String The contents of the specified field.

getString

public java.lang.String getString()
Get a String from the first field.

Returns:
String The contents of the first field.

getInt

public int getInt(int field)
Get an integer from a specified input field

Parameters:
field - The input field.
Returns:
int The contents of the specified field.

getInt

public int getInt()
Get an integer from the first input field

Returns:
int The contents of the first field.

getIntArray

public int[] getIntArray()
Get a int array from the input fields

Returns:
int[] containing the contents

getDouble

public double getDouble(int field)
Get a double from a specified input field

Parameters:
field - The input field.
Returns:
double The contents of the specified field.

getDouble

public double getDouble()
Get a double from the first input field

Returns:
double The contents of the specified field.

getDoubleArray

public double[] getDoubleArray()
Get a double array from the input fields

Returns:
double[] containing the contents

getBoolean

public boolean getBoolean()
Get a boolean from the checkbox input.

Returns:
boolean The boolean value

getSelectedIndex

public int getSelectedIndex()
Get the selected Index option from a pop-down ComboBox option list.

Returns:
int The chosen option

getSelectedItem

public java.lang.String getSelectedItem()
Get the selected item as a String from a pop-down ComboBox option list.

Returns:
String The chosen option