ti.swing
Class ConsoleTextArea

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byti.swing.console.Console
                      extended byti.swing.ConsoleTextArea
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class ConsoleTextArea
extends Console
implements java.io.Serializable

ConsoleTextArea is like a regular text area, except that you can getReader()/getWriter() to get a Reader/Writer that can be used for input/output with a non-GUI program. Because of this, ConsoleTextArea can be used as a console for non-GUI programs.

Version:
0.4
Author:
Rob Clark
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class ti.swing.console.Console
CR, LF
 
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
ConsoleTextArea()
          Class Constructor
ConsoleTextArea(int rows, int columns)
          Class Constructor.
ConsoleTextArea(int rows, int columns, boolean readonly)
          Class Constructor.
 
Method Summary
 void copy()
          Copy the selected text into the system-wide clipboard.
 void copy(java.awt.datatransfer.Clipboard clipboard)
          Copy the selected text into the provided clipboard.
 void dispose()
          This should called when getting rid of this text-area...
 java.lang.Object getHistory()
          Get the history.
 java.io.Reader getReader()
          Get the Reader for this console.
 java.io.Writer getWriter()
          Get the Writer for this console.
 boolean isManagingFocus()
          Overload so that non-read-only consoles don't let TAB change focus.
protected  void paintComponent(java.awt.Graphics g)
          Paint this component.
 void paste()
          Paste the text from the system-wide clipboard into the text area at the specified position.
 void paste(java.awt.datatransfer.Clipboard clipboard)
          Paste the text from the specified clipboard into the text area at the specified position.
 void paste(java.lang.String str)
          Paste the text into the text area.
protected  void scrollTo(java.awt.Point p)
          Scroll to a specified text coordinate.
 void selectAll()
          Select the entire buffer.
 void setHistory(java.lang.Object history)
          Set the history.
 void setTabCompleter(ConsoleTabCompleter ctc)
          Set the ConsoleTabCompleter
 
Methods inherited from class ti.swing.console.Console
doLayout, getInputHandler, getMinimumSize, getPreferredSize, processMouseEvent, setFont, setInputHandler, toOffset, toPoint, waitForRedraw
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, 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

ConsoleTextArea

public ConsoleTextArea()
Class Constructor


ConsoleTextArea

public ConsoleTextArea(int rows,
                       int columns)
Class Constructor. Create a standard read-write console.

Parameters:
rows - the number of rows for the console
columns - the number of columns for the console

ConsoleTextArea

public ConsoleTextArea(int rows,
                       int columns,
                       boolean readonly)
Class Constructor. Create a console window. If ro is true, then the console is "read-only", meaning that the user cannot type input into the console.

You can still get a reader for a "read-only" console, but because the user cannot enter any input there is probably no point in doing so.

Parameters:
rows - the number of rows for the console
columns - the number of columns for the console
readonly - true if this should be a read-only console
Method Detail

paintComponent

protected void paintComponent(java.awt.Graphics g)
Paint this component. We overload this so we have a chance to draw a cursor over things.

Overrides:
paintComponent in class Console

isManagingFocus

public boolean isManagingFocus()
Overload so that non-read-only consoles don't let TAB change focus.


scrollTo

protected void scrollTo(java.awt.Point p)
Scroll to a specified text coordinate. This method figures out the minimum amount of scrolling needed to make a particular text coordinate visible, and scrolls there, if it is not already visible.

Parameters:
p - the position to scroll to

setHistory

public void setHistory(java.lang.Object history)
Set the history. The history object must be an object that was previously returned by getHistory(), but may be serialized/deserialized.

Parameters:
history - a history object, as returned by getHistory()
See Also:
getHistory()

getHistory

public java.lang.Object getHistory()
Get the history. The history is externally treated as opaque, but the get/set methods allow the creator of the Console to make history persistant. The history object is Serializable

Returns:
a opaque history object, which is serializable
See Also:
setHistory(java.lang.Object)

setTabCompleter

public void setTabCompleter(ConsoleTabCompleter ctc)
Set the ConsoleTabCompleter


selectAll

public void selectAll()
Select the entire buffer.


copy

public void copy()
Copy the selected text into the system-wide clipboard.


copy

public void copy(java.awt.datatransfer.Clipboard clipboard)
Copy the selected text into the provided clipboard. If no text is selected, this is a no-op.

Parameters:
clipboard - the clipboard to copy into

paste

public void paste()
Paste the text from the system-wide clipboard into the text area at the specified position. If the data in the clipboard is not text, then this is a no-op.


paste

public void paste(java.awt.datatransfer.Clipboard clipboard)
Paste the text from the specified clipboard into the text area at the specified position. If the data in the clipboard is not text, then this is a no-op.

Parameters:
clipboard - the clipboard to copy from

paste

public void paste(java.lang.String str)
Paste the text into the text area.

Parameters:
str - the string to paste.

dispose

public void dispose()
This should called when getting rid of this text-area... this will cause any blocking readers to return.


getWriter

public java.io.Writer getWriter()
Get the Writer for this console. By using this writer, an application can use this console for output.

Returns:
a writer that can be used to write into the console

getReader

public java.io.Reader getReader()
Get the Reader for this console. By using this reader, an application can use this console for input.

Returns:
a reader that can be used to read from the console