uk.ac.ed.ph.sciprog
Class Input
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
uk.ac.ed.ph.sciprog.Input
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible
public class Input
- extends 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
Constructor Summary |
Input(String prompt,
boolean defaultBoolean)
Constuctor to deal with Boolean input via a JComboBox |
Input(String prompt,
double defaultDouble)
Constructor to setup input field to read a single double |
Input(String prompt,
double[] defaultDoubles)
Constructor to setup input field to read multiple doubles |
Input(String prompt,
int defaultInt)
Constructor to setup input field to read a single integer |
Input(String prompt,
int[] defaultInts)
Constructor to setup input field to read multiple ints |
Input(String prompt,
String defaultInput)
Constructor to setup input field to read a single String |
Input(String prompt,
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. |
String |
getSelectedItem()
Get the selected item as a String from a pop-down ComboBox
option list. |
String |
getString()
Get a String from the first field. |
String |
getString(int field)
Get a String from a specified input field |
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 |
Input
public Input(String prompt,
String defaultInput)
- Constructor to setup input field to read a single String
- Parameters:
prompt
- The prompt that appears on the input paneldefaultInput
- The default appearing in the panel
Input
public Input(String prompt,
int defaultInt)
- Constructor to setup input field to read a single integer
- Parameters:
prompt
- The prompt that appears on the input paneldefaultInt
- The default appearing in the panel
Input
public Input(String prompt,
double defaultDouble)
- Constructor to setup input field to read a single double
- Parameters:
prompt
- The prompt that appears on the input paneldefaultDouble
- The default appearing in the panel
Input
public Input(String prompt,
int[] defaultInts)
- Constructor to setup input field to read multiple ints
- Parameters:
prompt
- The prompt that appears on the input paneldefaultInts
- The default appearing in the panel.
length of array determines the number of input fields.
Input
public Input(String prompt,
double[] defaultDoubles)
- Constructor to setup input field to read multiple doubles
- Parameters:
prompt
- The prompt that appears on the input paneldefaultDoubles
- The default appearing in the panel.
length of array determines the number of input fields.
Input
public Input(String prompt,
String[] options,
int defaultOption)
- Constructor to give a pop-down box with an String array of
options.
- Parameters:
prompt
- The promptoptions
- array of optionsdefaultOption
- selected default option.
Input
public Input(String prompt,
boolean defaultBoolean)
- Constuctor to deal with Boolean input via a JComboBox
- Parameters:
prompt
- The prompt string.defaultBoolean
- Initial state of button
getString
public 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 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 String getSelectedItem()
- Get the selected item as a String from a pop-down ComboBox
option list.
- Returns:
String
The chosen option