Mp3dings 
20100427

de.mospace.swing
Class IOPane

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 de.mospace.swing.IOPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
ProcessIOPane

public class IOPane
extends JPanel

An IOPane consists of an input text field and a scrollable output text area. The input text field is equipped with a history, i. e. you can access previously entered items using the cursor keys. The output text area is automatically scrolled to the bottom when new text is appended. By default text that is entered in the input field is echoed in the output area and no other action is taken.

Version:
$Revision: 102 $ ($Date: 2007-11-05 12:28:41 +0100 (Mo, 05 Nov 2007) $)
Author:
Moritz Ringler
See Also:
ProcessIOPane, Serialized Form

Nested Class Summary
static interface IOPane.History
          Minimum requirements for a command line history for the input field of an IOPane.
static class IOPane.VectorHistory
          Default implementation of the IOPane.History interface.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  ActionListener echoAL
          The action listener that echoes input in the output field
protected  boolean prependPrompt
          whether to prepend a prompt sign to the echoed input
 
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
IOPane(int rows, int cols)
          Creates a new IOPane with no initial text.
 
Method Summary
 void addActionListener(ActionListener a)
          Adds the specified action listener to receive action events from the input textfield.
 void append(String s)
          Appends the given text to the end of the document of the output area.
 ActionListener[] getActionListeners()
          Returns an array of all the ActionListeners added to this IOPane with addActionListener(java.awt.event.ActionListener).
 Document getDocument()
          Fetches the model associated with the output area.
 IOPane.History getHistory()
          Fetches the command history of the input field.
protected  JTextField getInput()
          Returns the input text field of this IOPane.
 int getMaxLines()
          Returns the size limit of the output area of this IOPane.
protected  JTextArea getOutputArea()
          Returns the output area of this IOPane.
protected  JLabel getPrompt()
          Returns the Label preceding the input field of this IOPane.
protected  JScrollPane getScrollPane()
          Returns the ScrollPane containing the output area of this IOPane.
 void removeActionListener(ActionListener a)
          Removes the specified action listener so that it no longer receives action events from the input textfield.
 void setBackground(Color c)
          Sets the background color of this IOPane, its output area and its input field.
 void setMaxLines(int lines)
          Sets the maximum number of lines in the output area.
 
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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prependPrompt

protected boolean prependPrompt
whether to prepend a prompt sign to the echoed input


echoAL

protected final ActionListener echoAL
The action listener that echoes input in the output field

Constructor Detail

IOPane

public IOPane(int rows,
              int cols)
Creates a new IOPane with no initial text.

Parameters:
rows - number of text rows >= 0
cols - number of text columns >= 0 in a row
Throws:
IllegalArgumentException - if the rows or columns arguments are negative.
Method Detail

getActionListeners

public ActionListener[] getActionListeners()
Returns an array of all the ActionListeners added to this IOPane with addActionListener(java.awt.event.ActionListener).

Returns:
all of the ActionListeners added or an empty array if no listeners have been added

setBackground

public final void setBackground(Color c)
Sets the background color of this IOPane, its output area and its input field.

Overrides:
setBackground in class JComponent
Parameters:
c - the desired background Color

getDocument

public Document getDocument()
Fetches the model associated with the output area.

Returns:
the model of the output area

getHistory

public IOPane.History getHistory()
Fetches the command history of the input field.

Returns:
the command history

setMaxLines

public void setMaxLines(int lines)
Sets the maximum number of lines in the output area. When the text in the output area exceeds the limit set by this method. Lines are removed from its beginning. The initial limit is 100 lines.

Parameters:
lines - the line limit, if lines is negative the number of lines is unlimited
See Also:
getMaxLines()

getMaxLines

public int getMaxLines()
Returns the size limit of the output area of this IOPane.

Returns:
the maximum number of lines in the ouput area
See Also:
setMaxLines(int)

addActionListener

public void addActionListener(ActionListener a)
Adds the specified action listener to receive action events from the input textfield.

Parameters:
a - the action listener to be added

append

public void append(String s)
Appends the given text to the end of the document of the output area.

Parameters:
s - the text to append
See Also:
JTextArea.append(java.lang.String)

removeActionListener

public void removeActionListener(ActionListener a)
Removes the specified action listener so that it no longer receives action events from the input textfield.

Parameters:
a - the action listener to be removed

getInput

protected JTextField getInput()
Returns the input text field of this IOPane.

Returns:
the input text field

getOutputArea

protected JTextArea getOutputArea()
Returns the output area of this IOPane.

Returns:
the output area.

getPrompt

protected JLabel getPrompt()
Returns the Label preceding the input field of this IOPane.

Returns:
the JLabel preceding the input field

getScrollPane

protected JScrollPane getScrollPane()
Returns the ScrollPane containing the output area of this IOPane.

Returns:
the scroll pane of the output area

Mp3dings 
20100427