java.awt
Class TextArea

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.TextComponent
              |
              +--java.awt.TextArea
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class TextArea
extends TextComponent

A TextArea object is a multi-line region that displays text. It can be set to allow editing or to be read-only.

The following image shows the appearance of a text area:

This text area could be created by the following line of code:


 new TextArea("Hello", 5, 40);
 

Since:
JDK1.0
See Also:
Serialized Form

Inner Class Summary
protected  class TextArea.AccessibleAWTTextArea
TextArea.AccessibleAWTTextArea
This class implements accessibility support for the TextArea class. It provides an implementation of the Java Accessibility API appropriate to text area user-interface elements.
 
Inner classes inherited from class java.awt.TextComponent
TextComponent.AccessibleAWTTextComponent
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent
 
Field Summary
static int SCROLLBARS_BOTH
copy->  SCROLLBARS_BOTH
Create and display both vertical and horizontal scrollbars.
Since:
JDK1.1
static int SCROLLBARS_HORIZONTAL_ONLY
copy->  SCROLLBARS_HORIZONTAL_ONLY
Create and display horizontal scrollbar only.
Since:
JDK1.1
static int SCROLLBARS_NONE
copy->  SCROLLBARS_NONE
Do not create or display any scrollbars for the text area.
Since:
JDK1.1
static int SCROLLBARS_VERTICAL_ONLY
copy->  SCROLLBARS_VERTICAL_ONLY
Create and display vertical scrollbar only.
Since:
JDK1.1
 
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
copy->  new TextArea()
copy->  <TextArea var> = new TextArea();
Constructs a new text area. This text area is created with scrollbar visibility equal to SCROLLBARS_BOTH, so both vertical and horizontal scrollbars will be visible for this text area.
TextArea
copy->  new TextArea(, )
copy->  <TextArea var> = new TextArea(<int rows>, <int columns>);
Constructs a new empty text area with the specified number of rows and columns. A column is an approximate average character width that is platform-dependent. The text area is created with scrollbar visibility equal to SCROLLBARS_BOTH, so both vertical and horizontal scrollbars will be visible for this text area.
Parameters:
rows - the number of rows
columns - the number of columns
TextArea
copy->  new TextArea( )
copy->  <TextArea var> = new TextArea(<String text>);
Constructs a new text area with the specified text. This text area is created with scrollbar visibility equal to SCROLLBARS_BOTH, so both vertical and horizontal scrollbars will be visible for this text area.
Parameters:
text - the text to be displayed.
TextArea
copy->  new TextArea(, , )
copy->  <TextArea var> = new TextArea(<String text>, <int rows>, <int columns>);
Constructs a new text area with the specified text, and with the specified number of rows and columns. A column is an approximate average character width that is platform-dependent. The text area is created with scrollbar visibility equal to SCROLLBARS_BOTH, so both vertical and horizontal scrollbars will be visible for this text area.
Parameters:
text - the text to be displayed.
rows - the number of rows.
columns - the number of columns.
TextArea
copy->  new TextArea(, , , )
copy->  <TextArea var> = new TextArea(<String text>, <int rows>, <int columns>, <int scrollbars>);
Constructs a new text area with the specified text, and with the rows, columns, and scroll bar visibility as specified.

The TextArea class defines several constants that can be supplied as values for the scrollbars argument: SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, and SCROLLBARS_NONE. Any other value for the scrollbars argument is invalid and will result in this text area being created with scrollbar visibility equal to the default value of SCROLLBARS_BOTH.

Parameters:
text - the text to be displayed. If text is null, the empty string "" will be displayed.
rows - the number of rows. If rows is less than 0, rows is set to 0.
columns - the number of columns. If columns is less than 0, columns is set to 0.
scrollbars - a constant that determines what scrollbars are created to view the text area.
Since:
JDK1.1
 
Method Summary
 void addNotify()
copy->  .addNotify()
copy->  <TextArea>.addNotify();
Creates the TextArea's peer. The peer allows us to modify the appearance of the TextArea without changing any of its functionality.
Overrides:
addNotify in class Component
Following copied from class: java.awt.Component
See Also:
Component.isDisplayable(), Component.removeNotify()
 void append(String str)
copy->  .append( )
copy->  <TextArea>.append(<String str>);
Appends the given text to the text area's current text.
Parameters:
str - the text to append.
See Also:
insert(java.lang.String, int)
 void appendText(String str)
copy->  .appendText( )
copy->  <TextArea>.appendText(<String str>);
Deprecated. As of JDK version 1.1, replaced by append(String).

 AccessibleContext getAccessibleContext()
copy->  .getAccessibleContext()
copy->  <AccessibleContext var>=<TextArea>.getAccessibleContext();
Gets the AccessibleContext associated with this TextArea. For text areas, the AccessibleContext takes the form of an AccessibleAWTTextArea. A new AccessibleAWTTextArea instance is created if necessary.
Overrides:
getAccessibleContext in class TextComponent
Returns:
an AccessibleAWTTextArea that serves as the AccessibleContext of this TextArea
 int getColumns()
copy->  .getColumns()
copy->  <int var>=<TextArea>.getColumns();
Gets the number of columns in this text area.
Returns:
the number of columns in the text area.
See Also:
setColumns(int), getRows()
 Dimension getMinimumSize()
copy->  .getMinimumSize()
copy->  <Dimension var>=<TextArea>.getMinimumSize();
Determines the minimum size of this text area.
Overrides:
getMinimumSize in class Component
Returns:
the preferred dimensions needed for this text area.
Since:
JDK1.1
See Also:
Component.getPreferredSize()
 Dimension getMinimumSize(int rows, int columns)
copy->  .getMinimumSize(, )
copy->  <Dimension var>=<TextArea>.getMinimumSize(<int rows>, <int columns>);
Determines the minimum size of a text area with the specified number of rows and columns.
Parameters:
rows - the number of rows.
cols - the number of columns.
Returns:
the minimum dimensions required to display the text area with the specified number of rows and columns.
Since:
JDK1.1
See Also:
Component.getMinimumSize()
 Dimension getPreferredSize()
copy->  .getPreferredSize()
copy->  <Dimension var>=<TextArea>.getPreferredSize();
Determines the preferred size of this text area.
Overrides:
getPreferredSize in class Component
Returns:
the preferred dimensions needed for this text area.
Since:
JDK1.1
See Also:
Component.getPreferredSize()
 Dimension getPreferredSize(int rows, int columns)
copy->  .getPreferredSize(, )
copy->  <Dimension var>=<TextArea>.getPreferredSize(<int rows>, <int columns>);
Determines the preferred size of a text area with the specified number of rows and columns.
Parameters:
rows - the number of rows.
cols - the number of columns.
Returns:
the preferred dimensions required to display the text area with the specified number of rows and columns.
Since:
JDK1.1
See Also:
Component.getPreferredSize()
 int getRows()
copy->  .getRows()
copy->  <int var>=<TextArea>.getRows();
Gets the number of rows in the text area.
Returns:
the number of rows in the text area.
Since:
JDK1
See Also:
setRows(int), getColumns()
 int getScrollbarVisibility()
copy->  .getScrollbarVisibility()
copy->  <int var>=<TextArea>.getScrollbarVisibility();
Gets an enumerated value that indicates which scroll bars the text area uses.

The TextArea class defines four integer constants that are used to specify which scroll bars are available. TextArea has one constructor that gives the application discretion over scroll bars.

Returns:
an integer that indicates which scroll bars are used.
Since:
JDK1.1
See Also:
SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, TextArea(java.lang.String, int, int, int)
 void insert(String str, int pos)
copy->  .insert(, )
copy->  <TextArea>.insert(<String str>, <int pos>);
Inserts the specified text at the specified position in this text area.
Parameters:
str - the text to insert.
pos - the position at which to insert.
Since:
JDK1.1
See Also:
TextComponent.setText(java.lang.String), replaceRange(java.lang.String, int, int), append(java.lang.String)
 void insertText(String str, int pos)
copy->  .insertText(, )
copy->  <TextArea>.insertText(<String str>, <int pos>);
Deprecated. As of JDK version 1.1, replaced by insert(String, int).

 Dimension minimumSize()
copy->  .minimumSize()
copy->  <Dimension var>=<TextArea>.minimumSize();
Deprecated. As of JDK version 1.1, replaced by getMinimumSize().

Overrides:
minimumSize in class Component
 Dimension minimumSize(int rows, int columns)
copy->  .minimumSize(, )
copy->  <Dimension var>=<TextArea>.minimumSize(<int rows>, <int columns>);
Deprecated. As of JDK version 1.1, replaced by getMinimumSize(int, int).

protected  String paramString()
copy->  .paramString()
copy->  <String var>=<TextArea>.paramString();
Returns the parameter string representing the state of this text area. This string is useful for debugging.
Overrides:
paramString in class TextComponent
Returns:
the parameter string of this text area.
 Dimension preferredSize()
copy->  .preferredSize()
copy->  <Dimension var>=<TextArea>.preferredSize();
Deprecated. As of JDK version 1.1, replaced by getPreferredSize().

Overrides:
preferredSize in class Component
 Dimension preferredSize(int rows, int columns)
copy->  .preferredSize(, )
copy->  <Dimension var>=<TextArea>.preferredSize(<int rows>, <int columns>);
Deprecated. As of JDK version 1.1, replaced by getPreferredSize(int, int).

 void replaceRange(String str, int start, int end)
copy->  .replaceRange(, , )
copy->  <TextArea>.replaceRange(<String str>, <int start>, <int end>);
Replaces text between the indicated start and end positions with the specified replacement text.
Parameters:
str - the text to use as the replacement.
start - the start position.
end - the end position.
Since:
JDK1.1
See Also:
insert(java.lang.String, int)
 void replaceText(String str, int start, int end)
copy->  .replaceText(, , )
copy->  <TextArea>.replaceText(<String str>, <int start>, <int end>);
Deprecated. As of JDK version 1.1, replaced by replaceRange(String, int, int).

 void setColumns(int columns)
copy->  .setColumns( )
copy->  <TextArea>.setColumns(<int columns>);
Sets the number of columns for this text area.
Parameters:
columns - the number of columns.
Throws:
IllegalArgumentException - if the value supplied for columns is less than 0.
Since:
JDK1.1
See Also:
getColumns(), setRows(int)
 void setRows(int rows)
copy->  .setRows( )
copy->  <TextArea>.setRows(<int rows>);
Sets the number of rows for this text area.
Parameters:
rows - the number of rows.
Throws:
IllegalArgumentException - if the value supplied for rows is less than 0.
Since:
JDK1.1
See Also:
getRows(), setColumns(int)
 
Methods inherited from class java.awt.TextComponent
addTextListener, 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, enableInputMethods, 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