org.adougou.cline
Class TextArea

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.TextComponent
              |
              +--java.awt.TextArea
                    |
                    +--org.adougou.cline.TextArea
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.io.Serializable

public class TextArea
extends java.awt.TextArea
implements java.awt.event.KeyListener

This is a special TextArea for use with the TextAreaPrompt. It has the basic functionality of the java.awt.TextArea, however it has a KeyListener that controls how the user moves about.

See Also:
TextArea, TextAreaPrompt, Serialized Form

Inner classes inherited from class java.awt.TextArea
java.awt.TextArea.AccessibleAWTTextArea
 
Inner classes inherited from class java.awt.TextComponent
java.awt.TextComponent.AccessibleAWTTextComponent
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class java.awt.TextArea
SCROLLBARS_BOTH, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, SCROLLBARS_VERTICAL_ONLY
 
Fields inherited from class java.awt.TextComponent
textListener
 
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
TextArea(int numRows)
          Construct a new TextArea for use with the TextAreaPrompt.
TextArea(int numRows, int numColumns)
          Construct a new TextArea for use with the TextAreaPrompt.
 
Method Summary
 java.awt.Dimension getPreferredSize()
          The java.awt.TextArea.getPreferredSize() method seems to insist on making the TextArea slight larger than is required to fit the specified number of rows.
 void keyPressed(java.awt.event.KeyEvent e)
          Notes from the KeyEvent API documentation: keyTyped events are higher level and do not usually depend on the platform or keyboard layout.
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 
Methods inherited from class java.awt.TextArea
addNotify, append, appendText, getAccessibleContext, getColumns, getMinimumSize, getMinimumSize, getPreferredSize, getRows, getScrollbarVisibility, insert, insertText, minimumSize, minimumSize, paramString, preferredSize, preferredSize, replaceRange, replaceText, setColumns, setRows
 
Methods inherited from class java.awt.TextComponent
addTextListener, enableInputMethods, getBackground, getCaretPosition, getListeners, getSelectedText, getSelectionEnd, getSelectionStart, getText, isEditable, processEvent, processTextEvent, removeNotify, removeTextListener, select, selectAll, setBackground, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, firePropertyChange, getAlignmentX, getAlignmentY, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextArea

public TextArea(int numRows)
Construct a new TextArea for use with the TextAreaPrompt. Uses the default number of columns (TextArea.DEFAULT_COLUMNS).
Parameters:
numRows - the number of lines that will fit into the text area.

TextArea

public TextArea(int numRows,
                int numColumns)
Construct a new TextArea for use with the TextAreaPrompt.
Parameters:
numRows - the number of lines that will fit into the text area.
numColumns - the number of characters that will fit into the text area.
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
The java.awt.TextArea.getPreferredSize() method seems to insist on making the TextArea slight larger than is required to fit the specified number of rows. My solution is to overload the getPreferredSize() method and slightly reduce the dimension height.
Overrides:
getPreferredSize in class java.awt.TextArea

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Notes from the KeyEvent API documentation: keyTyped events are higher level and do not usually depend on the platform or keyboard layout. KeyPressed and KeyReleased events are lower-level are platform dependent. All key-processing for the TextArea makes use of keyPressed events since we want to capture special KeyEvents such as HOME, ENTER, arrow keys etc..
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener