TextArea (Java Platform SE 8 ) (original) (raw)
- java.awt.Component
- java.awt.TextComponent
- java.awt.TextArea
- java.awt.TextComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
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
Nested Class Summary
Nested Classes
Modifier and Type Class Description protected class TextArea.AccessibleAWTTextArea This class implements accessibility support for theTextArea class. * ### Nested classes/interfaces inherited from class java.awt.[TextComponent](../../java/awt/TextComponent.html "class in java.awt") `[TextComponent.AccessibleAWTTextComponent](../../java/awt/TextComponent.AccessibleAWTTextComponent.html "class in java.awt")` * ### Nested classes/interfaces inherited from class java.awt.[Component](../../java/awt/Component.html "class in java.awt") `[Component.AccessibleAWTComponent](../../java/awt/Component.AccessibleAWTComponent.html "class in java.awt"), [Component.BaselineResizeBehavior](../../java/awt/Component.BaselineResizeBehavior.html "enum in java.awt"), [Component.BltBufferStrategy](../../java/awt/Component.BltBufferStrategy.html "class in java.awt"), [Component.FlipBufferStrategy](../../java/awt/Component.FlipBufferStrategy.html "class in java.awt")`
Field Summary
Fields
Modifier and Type Field Description static int SCROLLBARS_BOTH Create and display both vertical and horizontal scrollbars. static int SCROLLBARS_HORIZONTAL_ONLY Create and display horizontal scrollbar only. static int SCROLLBARS_NONE Do not create or display any scrollbars for the text area. static int SCROLLBARS_VERTICAL_ONLY Create and display vertical scrollbar only. * ### Fields inherited from class java.awt.[TextComponent](../../java/awt/TextComponent.html "class in java.awt") `[textListener](../../java/awt/TextComponent.html#textListener)` * ### Fields inherited from class java.awt.[Component](../../java/awt/Component.html "class in java.awt") `[accessibleContext](../../java/awt/Component.html#accessibleContext), [BOTTOM_ALIGNMENT](../../java/awt/Component.html#BOTTOM%5FALIGNMENT), [CENTER_ALIGNMENT](../../java/awt/Component.html#CENTER%5FALIGNMENT), [LEFT_ALIGNMENT](../../java/awt/Component.html#LEFT%5FALIGNMENT), [RIGHT_ALIGNMENT](../../java/awt/Component.html#RIGHT%5FALIGNMENT), [TOP_ALIGNMENT](../../java/awt/Component.html#TOP%5FALIGNMENT)` * ### Fields inherited from interface java.awt.image.[ImageObserver](../../java/awt/image/ImageObserver.html "interface in java.awt.image") `[ABORT](../../java/awt/image/ImageObserver.html#ABORT), [ALLBITS](../../java/awt/image/ImageObserver.html#ALLBITS), [ERROR](../../java/awt/image/ImageObserver.html#ERROR), [FRAMEBITS](../../java/awt/image/ImageObserver.html#FRAMEBITS), [HEIGHT](../../java/awt/image/ImageObserver.html#HEIGHT), [PROPERTIES](../../java/awt/image/ImageObserver.html#PROPERTIES), [SOMEBITS](../../java/awt/image/ImageObserver.html#SOMEBITS), [WIDTH](../../java/awt/image/ImageObserver.html#WIDTH)`
Constructor Summary
Constructors
Constructor Description TextArea() Constructs a new text area with the empty string as text. TextArea(int rows, int columns) Constructs a new text area with the specified number of rows and columns and the empty string as text. TextArea(String text) Constructs a new text area with the specified text. 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. 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. Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods
Modifier and Type Method Description void addNotify() Creates the TextArea's peer. void append(String str) Appends the given text to the text area's current text. void appendText(String str) Deprecated. AccessibleContext getAccessibleContext() Returns the AccessibleContext associated with this TextArea. int getColumns() Returns the number of columns in this text area. Dimension getMinimumSize() Determines the minimum size of this text area. Dimension getMinimumSize(int rows, int columns) Determines the minimum size of a text area with the specified number of rows and columns. Dimension getPreferredSize() Determines the preferred size of this text area. Dimension getPreferredSize(int rows, int columns) Determines the preferred size of a text area with the specified number of rows and columns. int getRows() Returns the number of rows in the text area. int getScrollbarVisibility() Returns an enumerated value that indicates which scroll bars the text area uses. void insert(String str, int pos) Inserts the specified text at the specified position in this text area. void insertText(String str, int pos) Deprecated. Dimension minimumSize() Deprecated. Dimension minimumSize(int rows, int columns) Deprecated. protected String paramString() Returns a string representing the state of this TextArea. Dimension preferredSize() Deprecated. Dimension preferredSize(int rows, int columns) Deprecated. void replaceRange(String str, int start, int end) Replaces text between the indicated start and end positions with the specified replacement text. void replaceText(String str, int start, int end) Deprecated. void setColumns(int columns) Sets the number of columns for this text area. void setRows(int rows) Sets the number of rows for this text area. * ### Methods inherited from class java.awt.[TextComponent](../../java/awt/TextComponent.html "class in java.awt") `[addTextListener](../../java/awt/TextComponent.html#addTextListener-java.awt.event.TextListener-), [enableInputMethods](../../java/awt/TextComponent.html#enableInputMethods-boolean-), [getBackground](../../java/awt/TextComponent.html#getBackground--), [getCaretPosition](../../java/awt/TextComponent.html#getCaretPosition--), [getInputMethodRequests](../../java/awt/TextComponent.html#getInputMethodRequests--), [getListeners](../../java/awt/TextComponent.html#getListeners-java.lang.Class-), [getSelectedText](../../java/awt/TextComponent.html#getSelectedText--), [getSelectionEnd](../../java/awt/TextComponent.html#getSelectionEnd--), [getSelectionStart](../../java/awt/TextComponent.html#getSelectionStart--), [getText](../../java/awt/TextComponent.html#getText--), [getTextListeners](../../java/awt/TextComponent.html#getTextListeners--), [isEditable](../../java/awt/TextComponent.html#isEditable--), [processEvent](../../java/awt/TextComponent.html#processEvent-java.awt.AWTEvent-), [processTextEvent](../../java/awt/TextComponent.html#processTextEvent-java.awt.event.TextEvent-), [removeNotify](../../java/awt/TextComponent.html#removeNotify--), [removeTextListener](../../java/awt/TextComponent.html#removeTextListener-java.awt.event.TextListener-), [select](../../java/awt/TextComponent.html#select-int-int-), [selectAll](../../java/awt/TextComponent.html#selectAll--), [setBackground](../../java/awt/TextComponent.html#setBackground-java.awt.Color-), [setCaretPosition](../../java/awt/TextComponent.html#setCaretPosition-int-), [setEditable](../../java/awt/TextComponent.html#setEditable-boolean-), [setSelectionEnd](../../java/awt/TextComponent.html#setSelectionEnd-int-), [setSelectionStart](../../java/awt/TextComponent.html#setSelectionStart-int-), [setText](../../java/awt/TextComponent.html#setText-java.lang.String-)` * ### Methods inherited from class java.awt.[Component](../../java/awt/Component.html "class in java.awt") `[action](../../java/awt/Component.html#action-java.awt.Event-java.lang.Object-), [add](../../java/awt/Component.html#add-java.awt.PopupMenu-), [addComponentListener](../../java/awt/Component.html#addComponentListener-java.awt.event.ComponentListener-), [addFocusListener](../../java/awt/Component.html#addFocusListener-java.awt.event.FocusListener-), [addHierarchyBoundsListener](../../java/awt/Component.html#addHierarchyBoundsListener-java.awt.event.HierarchyBoundsListener-), [addHierarchyListener](../../java/awt/Component.html#addHierarchyListener-java.awt.event.HierarchyListener-), [addInputMethodListener](../../java/awt/Component.html#addInputMethodListener-java.awt.event.InputMethodListener-), [addKeyListener](../../java/awt/Component.html#addKeyListener-java.awt.event.KeyListener-), [addMouseListener](../../java/awt/Component.html#addMouseListener-java.awt.event.MouseListener-), [addMouseMotionListener](../../java/awt/Component.html#addMouseMotionListener-java.awt.event.MouseMotionListener-), [addMouseWheelListener](../../java/awt/Component.html#addMouseWheelListener-java.awt.event.MouseWheelListener-), [addPropertyChangeListener](../../java/awt/Component.html#addPropertyChangeListener-java.beans.PropertyChangeListener-), [addPropertyChangeListener](../../java/awt/Component.html#addPropertyChangeListener-java.lang.String-java.beans.PropertyChangeListener-), [applyComponentOrientation](../../java/awt/Component.html#applyComponentOrientation-java.awt.ComponentOrientation-), [areFocusTraversalKeysSet](../../java/awt/Component.html#areFocusTraversalKeysSet-int-), [bounds](../../java/awt/Component.html#bounds--), [checkImage](../../java/awt/Component.html#checkImage-java.awt.Image-java.awt.image.ImageObserver-), [checkImage](../../java/awt/Component.html#checkImage-java.awt.Image-int-int-java.awt.image.ImageObserver-), [coalesceEvents](../../java/awt/Component.html#coalesceEvents-java.awt.AWTEvent-java.awt.AWTEvent-), [contains](../../java/awt/Component.html#contains-int-int-), [contains](../../java/awt/Component.html#contains-java.awt.Point-), [createImage](../../java/awt/Component.html#createImage-java.awt.image.ImageProducer-), [createImage](../../java/awt/Component.html#createImage-int-int-), [createVolatileImage](../../java/awt/Component.html#createVolatileImage-int-int-), [createVolatileImage](../../java/awt/Component.html#createVolatileImage-int-int-java.awt.ImageCapabilities-), [deliverEvent](../../java/awt/Component.html#deliverEvent-java.awt.Event-), [disable](../../java/awt/Component.html#disable--), [disableEvents](../../java/awt/Component.html#disableEvents-long-), [dispatchEvent](../../java/awt/Component.html#dispatchEvent-java.awt.AWTEvent-), [doLayout](../../java/awt/Component.html#doLayout--), [enable](../../java/awt/Component.html#enable--), [enable](../../java/awt/Component.html#enable-boolean-), [enableEvents](../../java/awt/Component.html#enableEvents-long-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-boolean-boolean-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-byte-byte-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-char-char-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-double-double-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-float-float-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-int-int-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-long-long-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-java.lang.Object-java.lang.Object-), [firePropertyChange](../../java/awt/Component.html#firePropertyChange-java.lang.String-short-short-), [getAlignmentX](../../java/awt/Component.html#getAlignmentX--), [getAlignmentY](../../java/awt/Component.html#getAlignmentY--), [getBaseline](../../java/awt/Component.html#getBaseline-int-int-), [getBaselineResizeBehavior](../../java/awt/Component.html#getBaselineResizeBehavior--), [getBounds](../../java/awt/Component.html#getBounds--), [getBounds](../../java/awt/Component.html#getBounds-java.awt.Rectangle-), [getColorModel](../../java/awt/Component.html#getColorModel--), [getComponentAt](../../java/awt/Component.html#getComponentAt-int-int-), [getComponentAt](../../java/awt/Component.html#getComponentAt-java.awt.Point-), [getComponentListeners](../../java/awt/Component.html#getComponentListeners--), [getComponentOrientation](../../java/awt/Component.html#getComponentOrientation--), [getCursor](../../java/awt/Component.html#getCursor--), [getDropTarget](../../java/awt/Component.html#getDropTarget--), [getFocusCycleRootAncestor](../../java/awt/Component.html#getFocusCycleRootAncestor--), [getFocusListeners](../../java/awt/Component.html#getFocusListeners--), [getFocusTraversalKeys](../../java/awt/Component.html#getFocusTraversalKeys-int-), [getFocusTraversalKeysEnabled](../../java/awt/Component.html#getFocusTraversalKeysEnabled--), [getFont](../../java/awt/Component.html#getFont--), [getFontMetrics](../../java/awt/Component.html#getFontMetrics-java.awt.Font-), [getForeground](../../java/awt/Component.html#getForeground--), [getGraphics](../../java/awt/Component.html#getGraphics--), [getGraphicsConfiguration](../../java/awt/Component.html#getGraphicsConfiguration--), [getHeight](../../java/awt/Component.html#getHeight--), [getHierarchyBoundsListeners](../../java/awt/Component.html#getHierarchyBoundsListeners--), [getHierarchyListeners](../../java/awt/Component.html#getHierarchyListeners--), [getIgnoreRepaint](../../java/awt/Component.html#getIgnoreRepaint--), [getInputContext](../../java/awt/Component.html#getInputContext--), [getInputMethodListeners](../../java/awt/Component.html#getInputMethodListeners--), [getKeyListeners](../../java/awt/Component.html#getKeyListeners--), [getLocale](../../java/awt/Component.html#getLocale--), [getLocation](../../java/awt/Component.html#getLocation--), [getLocation](../../java/awt/Component.html#getLocation-java.awt.Point-), [getLocationOnScreen](../../java/awt/Component.html#getLocationOnScreen--), [getMaximumSize](../../java/awt/Component.html#getMaximumSize--), [getMouseListeners](../../java/awt/Component.html#getMouseListeners--), [getMouseMotionListeners](../../java/awt/Component.html#getMouseMotionListeners--), [getMousePosition](../../java/awt/Component.html#getMousePosition--), [getMouseWheelListeners](../../java/awt/Component.html#getMouseWheelListeners--), [getName](../../java/awt/Component.html#getName--), [getParent](../../java/awt/Component.html#getParent--), [getPeer](../../java/awt/Component.html#getPeer--), [getPropertyChangeListeners](../../java/awt/Component.html#getPropertyChangeListeners--), [getPropertyChangeListeners](../../java/awt/Component.html#getPropertyChangeListeners-java.lang.String-), [getSize](../../java/awt/Component.html#getSize--), [getSize](../../java/awt/Component.html#getSize-java.awt.Dimension-), [getToolkit](../../java/awt/Component.html#getToolkit--), [getTreeLock](../../java/awt/Component.html#getTreeLock--), [getWidth](../../java/awt/Component.html#getWidth--), [getX](../../java/awt/Component.html#getX--), [getY](../../java/awt/Component.html#getY--), [gotFocus](../../java/awt/Component.html#gotFocus-java.awt.Event-java.lang.Object-), [handleEvent](../../java/awt/Component.html#handleEvent-java.awt.Event-), [hasFocus](../../java/awt/Component.html#hasFocus--), [hide](../../java/awt/Component.html#hide--), [imageUpdate](../../java/awt/Component.html#imageUpdate-java.awt.Image-int-int-int-int-int-), [inside](../../java/awt/Component.html#inside-int-int-), [invalidate](../../java/awt/Component.html#invalidate--), [isBackgroundSet](../../java/awt/Component.html#isBackgroundSet--), [isCursorSet](../../java/awt/Component.html#isCursorSet--), [isDisplayable](../../java/awt/Component.html#isDisplayable--), [isDoubleBuffered](../../java/awt/Component.html#isDoubleBuffered--), [isEnabled](../../java/awt/Component.html#isEnabled--), [isFocusable](../../java/awt/Component.html#isFocusable--), [isFocusCycleRoot](../../java/awt/Component.html#isFocusCycleRoot-java.awt.Container-), [isFocusOwner](../../java/awt/Component.html#isFocusOwner--), [isFocusTraversable](../../java/awt/Component.html#isFocusTraversable--), [isFontSet](../../java/awt/Component.html#isFontSet--), [isForegroundSet](../../java/awt/Component.html#isForegroundSet--), [isLightweight](../../java/awt/Component.html#isLightweight--), [isMaximumSizeSet](../../java/awt/Component.html#isMaximumSizeSet--), [isMinimumSizeSet](../../java/awt/Component.html#isMinimumSizeSet--), [isOpaque](../../java/awt/Component.html#isOpaque--), [isPreferredSizeSet](../../java/awt/Component.html#isPreferredSizeSet--), [isShowing](../../java/awt/Component.html#isShowing--), [isValid](../../java/awt/Component.html#isValid--), [isVisible](../../java/awt/Component.html#isVisible--), [keyDown](../../java/awt/Component.html#keyDown-java.awt.Event-int-), [keyUp](../../java/awt/Component.html#keyUp-java.awt.Event-int-), [layout](../../java/awt/Component.html#layout--), [list](../../java/awt/Component.html#list--), [list](../../java/awt/Component.html#list-java.io.PrintStream-), [list](../../java/awt/Component.html#list-java.io.PrintStream-int-), [list](../../java/awt/Component.html#list-java.io.PrintWriter-), [list](../../java/awt/Component.html#list-java.io.PrintWriter-int-), [locate](../../java/awt/Component.html#locate-int-int-), [location](../../java/awt/Component.html#location--), [lostFocus](../../java/awt/Component.html#lostFocus-java.awt.Event-java.lang.Object-), [mouseDown](../../java/awt/Component.html#mouseDown-java.awt.Event-int-int-), [mouseDrag](../../java/awt/Component.html#mouseDrag-java.awt.Event-int-int-), [mouseEnter](../../java/awt/Component.html#mouseEnter-java.awt.Event-int-int-), [mouseExit](../../java/awt/Component.html#mouseExit-java.awt.Event-int-int-), [mouseMove](../../java/awt/Component.html#mouseMove-java.awt.Event-int-int-), [mouseUp](../../java/awt/Component.html#mouseUp-java.awt.Event-int-int-), [move](../../java/awt/Component.html#move-int-int-), [nextFocus](../../java/awt/Component.html#nextFocus--), [paint](../../java/awt/Component.html#paint-java.awt.Graphics-), [paintAll](../../java/awt/Component.html#paintAll-java.awt.Graphics-), [postEvent](../../java/awt/Component.html#postEvent-java.awt.Event-), [prepareImage](../../java/awt/Component.html#prepareImage-java.awt.Image-java.awt.image.ImageObserver-), [prepareImage](../../java/awt/Component.html#prepareImage-java.awt.Image-int-int-java.awt.image.ImageObserver-), [print](../../java/awt/Component.html#print-java.awt.Graphics-), [printAll](../../java/awt/Component.html#printAll-java.awt.Graphics-), [processComponentEvent](../../java/awt/Component.html#processComponentEvent-java.awt.event.ComponentEvent-), [processFocusEvent](../../java/awt/Component.html#processFocusEvent-java.awt.event.FocusEvent-), [processHierarchyBoundsEvent](../../java/awt/Component.html#processHierarchyBoundsEvent-java.awt.event.HierarchyEvent-), [processHierarchyEvent](../../java/awt/Component.html#processHierarchyEvent-java.awt.event.HierarchyEvent-), [processInputMethodEvent](../../java/awt/Component.html#processInputMethodEvent-java.awt.event.InputMethodEvent-), [processKeyEvent](../../java/awt/Component.html#processKeyEvent-java.awt.event.KeyEvent-), [processMouseEvent](../../java/awt/Component.html#processMouseEvent-java.awt.event.MouseEvent-), [processMouseMotionEvent](../../java/awt/Component.html#processMouseMotionEvent-java.awt.event.MouseEvent-), [processMouseWheelEvent](../../java/awt/Component.html#processMouseWheelEvent-java.awt.event.MouseWheelEvent-), [remove](../../java/awt/Component.html#remove-java.awt.MenuComponent-), [removeComponentListener](../../java/awt/Component.html#removeComponentListener-java.awt.event.ComponentListener-), [removeFocusListener](../../java/awt/Component.html#removeFocusListener-java.awt.event.FocusListener-), [removeHierarchyBoundsListener](../../java/awt/Component.html#removeHierarchyBoundsListener-java.awt.event.HierarchyBoundsListener-), [removeHierarchyListener](../../java/awt/Component.html#removeHierarchyListener-java.awt.event.HierarchyListener-), [removeInputMethodListener](../../java/awt/Component.html#removeInputMethodListener-java.awt.event.InputMethodListener-), [removeKeyListener](../../java/awt/Component.html#removeKeyListener-java.awt.event.KeyListener-), [removeMouseListener](../../java/awt/Component.html#removeMouseListener-java.awt.event.MouseListener-), [removeMouseMotionListener](../../java/awt/Component.html#removeMouseMotionListener-java.awt.event.MouseMotionListener-), [removeMouseWheelListener](../../java/awt/Component.html#removeMouseWheelListener-java.awt.event.MouseWheelListener-), [removePropertyChangeListener](../../java/awt/Component.html#removePropertyChangeListener-java.beans.PropertyChangeListener-), [removePropertyChangeListener](../../java/awt/Component.html#removePropertyChangeListener-java.lang.String-java.beans.PropertyChangeListener-), [repaint](../../java/awt/Component.html#repaint--), [repaint](../../java/awt/Component.html#repaint-int-int-int-int-), [repaint](../../java/awt/Component.html#repaint-long-), [repaint](../../java/awt/Component.html#repaint-long-int-int-int-int-), [requestFocus](../../java/awt/Component.html#requestFocus--), [requestFocus](../../java/awt/Component.html#requestFocus-boolean-), [requestFocusInWindow](../../java/awt/Component.html#requestFocusInWindow--), [requestFocusInWindow](../../java/awt/Component.html#requestFocusInWindow-boolean-), [reshape](../../java/awt/Component.html#reshape-int-int-int-int-), [resize](../../java/awt/Component.html#resize-java.awt.Dimension-), [resize](../../java/awt/Component.html#resize-int-int-), [revalidate](../../java/awt/Component.html#revalidate--), [setBounds](../../java/awt/Component.html#setBounds-int-int-int-int-), [setBounds](../../java/awt/Component.html#setBounds-java.awt.Rectangle-), [setComponentOrientation](../../java/awt/Component.html#setComponentOrientation-java.awt.ComponentOrientation-), [setCursor](../../java/awt/Component.html#setCursor-java.awt.Cursor-), [setDropTarget](../../java/awt/Component.html#setDropTarget-java.awt.dnd.DropTarget-), [setEnabled](../../java/awt/Component.html#setEnabled-boolean-), [setFocusable](../../java/awt/Component.html#setFocusable-boolean-), [setFocusTraversalKeys](../../java/awt/Component.html#setFocusTraversalKeys-int-java.util.Set-), [setFocusTraversalKeysEnabled](../../java/awt/Component.html#setFocusTraversalKeysEnabled-boolean-), [setFont](../../java/awt/Component.html#setFont-java.awt.Font-), [setForeground](../../java/awt/Component.html#setForeground-java.awt.Color-), [setIgnoreRepaint](../../java/awt/Component.html#setIgnoreRepaint-boolean-), [setLocale](../../java/awt/Component.html#setLocale-java.util.Locale-), [setLocation](../../java/awt/Component.html#setLocation-int-int-), [setLocation](../../java/awt/Component.html#setLocation-java.awt.Point-), [setMaximumSize](../../java/awt/Component.html#setMaximumSize-java.awt.Dimension-), [setMinimumSize](../../java/awt/Component.html#setMinimumSize-java.awt.Dimension-), [setName](../../java/awt/Component.html#setName-java.lang.String-), [setPreferredSize](../../java/awt/Component.html#setPreferredSize-java.awt.Dimension-), [setSize](../../java/awt/Component.html#setSize-java.awt.Dimension-), [setSize](../../java/awt/Component.html#setSize-int-int-), [setVisible](../../java/awt/Component.html#setVisible-boolean-), [show](../../java/awt/Component.html#show--), [show](../../java/awt/Component.html#show-boolean-), [size](../../java/awt/Component.html#size--), [toString](../../java/awt/Component.html#toString--), [transferFocus](../../java/awt/Component.html#transferFocus--), [transferFocusBackward](../../java/awt/Component.html#transferFocusBackward--), [transferFocusUpCycle](../../java/awt/Component.html#transferFocusUpCycle--), [update](../../java/awt/Component.html#update-java.awt.Graphics-), [validate](../../java/awt/Component.html#validate--)` * ### Methods inherited from class java.lang.[Object](../../java/lang/Object.html "class in java.lang") `[clone](../../java/lang/Object.html#clone--), [equals](../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../java/lang/Object.html#finalize--), [getClass](../../java/lang/Object.html#getClass--), [hashCode](../../java/lang/Object.html#hashCode--), [notify](../../java/lang/Object.html#notify--), [notifyAll](../../java/lang/Object.html#notifyAll--), [wait](../../java/lang/Object.html#wait--), [wait](../../java/lang/Object.html#wait-long-), [wait](../../java/lang/Object.html#wait-long-int-)`
Field Detail
* #### SCROLLBARS\_BOTH public static final int SCROLLBARS_BOTH Create and display both vertical and horizontal scrollbars. Since: JDK1.1 See Also: [Constant Field Values](../../constant-values.html#java.awt.TextArea.SCROLLBARS%5FBOTH) * #### SCROLLBARS\_VERTICAL\_ONLY public static final int SCROLLBARS_VERTICAL_ONLY Create and display vertical scrollbar only. Since: JDK1.1 See Also: [Constant Field Values](../../constant-values.html#java.awt.TextArea.SCROLLBARS%5FVERTICAL%5FONLY) * #### SCROLLBARS\_HORIZONTAL\_ONLY public static final int SCROLLBARS_HORIZONTAL_ONLY Create and display horizontal scrollbar only. Since: JDK1.1 See Also: [Constant Field Values](../../constant-values.html#java.awt.TextArea.SCROLLBARS%5FHORIZONTAL%5FONLY) * #### SCROLLBARS\_NONE public static final int SCROLLBARS_NONE Do not create or display any scrollbars for the text area. Since: JDK1.1 See Also: [Constant Field Values](../../constant-values.html#java.awt.TextArea.SCROLLBARS%5FNONE)
Constructor Detail
* #### TextArea public TextArea() throws [HeadlessException](../../java/awt/HeadlessException.html "class in java.awt") Constructs a new text area with the empty string as text. This text area is created with scrollbar visibility equal to[SCROLLBARS\_BOTH](../../java/awt/TextArea.html#SCROLLBARS%5FBOTH), so both vertical and horizontal scrollbars will be visible for this text area. Throws: `[HeadlessException](../../java/awt/HeadlessException.html "class in java.awt")` \- if`GraphicsEnvironment.isHeadless` returns true See Also: [GraphicsEnvironment.isHeadless()](../../java/awt/GraphicsEnvironment.html#isHeadless--) * #### TextArea public TextArea([String](../../java/lang/String.html "class in java.lang") text) throws [HeadlessException](../../java/awt/HeadlessException.html "class in java.awt") Constructs a new text area with the specified text. This text area is created with scrollbar visibility equal to[SCROLLBARS\_BOTH](../../java/awt/TextArea.html#SCROLLBARS%5FBOTH), so both vertical and horizontal scrollbars will be visible for this text area. Parameters: `text` \- the text to be displayed; if`text` is `null`, the empty string `""` will be displayed Throws: `[HeadlessException](../../java/awt/HeadlessException.html "class in java.awt")` \- if`GraphicsEnvironment.isHeadless` returns true See Also: [GraphicsEnvironment.isHeadless()](../../java/awt/GraphicsEnvironment.html#isHeadless--) * #### TextArea public TextArea(int rows, int columns) throws [HeadlessException](../../java/awt/HeadlessException.html "class in java.awt") Constructs a new text area with the specified number of rows and columns and the empty string as text. A column is an approximate average character width that is platform-dependent. The text area is created with scrollbar visibility equal to [SCROLLBARS\_BOTH](../../java/awt/TextArea.html#SCROLLBARS%5FBOTH), so both vertical and horizontal scrollbars will be visible for this text area. Parameters: `rows` \- the number of rows `columns` \- the number of columns Throws: `[HeadlessException](../../java/awt/HeadlessException.html "class in java.awt")` \- if`GraphicsEnvironment.isHeadless` returns true See Also: [GraphicsEnvironment.isHeadless()](../../java/awt/GraphicsEnvironment.html#isHeadless--) * #### TextArea public TextArea([String](../../java/lang/String.html "class in java.lang") text, int rows, int columns) throws [HeadlessException](../../java/awt/HeadlessException.html "class in java.awt") 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](../../java/awt/TextArea.html#SCROLLBARS%5FBOTH), so both vertical and horizontal scrollbars will be visible for this text area. Parameters: `text` \- the text to be displayed; if`text` is `null`, the empty string `""` will be displayed `rows` \- the number of rows `columns` \- the number of columns Throws: `[HeadlessException](../../java/awt/HeadlessException.html "class in java.awt")` \- if`GraphicsEnvironment.isHeadless` returns true See Also: [GraphicsEnvironment.isHeadless()](../../java/awt/GraphicsEnvironment.html#isHeadless--) * #### TextArea public TextArea([String](../../java/lang/String.html "class in java.lang") text, int rows, int columns, int scrollbars) throws [HeadlessException](../../java/awt/HeadlessException.html "class in java.awt") Constructs a new text area with the specified text, and with the rows, columns, and scroll bar visibility as specified. All `TextArea` constructors defer to this one. The `TextArea` class defines several constants that can be supplied as values for the`scrollbars` argument: * `SCROLLBARS_BOTH`, * `SCROLLBARS_VERTICAL_ONLY`, * `SCROLLBARS_HORIZONTAL_ONLY`, * `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](../../java/awt/TextArea.html#SCROLLBARS%5FBOTH). 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 Throws: `[HeadlessException](../../java/awt/HeadlessException.html "class in java.awt")` \- if`GraphicsEnvironment.isHeadless` returns true Since: JDK1.1 See Also: [GraphicsEnvironment.isHeadless()](../../java/awt/GraphicsEnvironment.html#isHeadless--)
Method Detail
* #### addNotify public void 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](../../java/awt/TextComponent.html#addNotify--)` in class `[TextComponent](../../java/awt/TextComponent.html "class in java.awt")` See Also: [TextComponent.removeNotify()](../../java/awt/TextComponent.html#removeNotify--) * #### insert public void insert([String](../../java/lang/String.html "class in java.lang") str, int pos) Inserts the specified text at the specified position in this text area. Note that passing `null` or inconsistent parameters is invalid and will result in unspecified behavior. Parameters: `str` \- the non-`null` text to insert `pos` \- the position at which to insert Since: JDK1.1 See Also: [TextComponent.setText(java.lang.String)](../../java/awt/TextComponent.html#setText-java.lang.String-), [replaceRange(java.lang.String, int, int)](../../java/awt/TextArea.html#replaceRange-java.lang.String-int-int-), [append(java.lang.String)](../../java/awt/TextArea.html#append-java.lang.String-) * #### insertText [@Deprecated](../../java/lang/Deprecated.html "annotation in java.lang") public void insertText([String](../../java/lang/String.html "class in java.lang") str, int pos) Deprecated. * #### append public void append([String](../../java/lang/String.html "class in java.lang") str) Appends the given text to the text area's current text. Note that passing `null` or inconsistent parameters is invalid and will result in unspecified behavior. Parameters: `str` \- the non-`null` text to append Since: JDK1.1 See Also: [insert(java.lang.String, int)](../../java/awt/TextArea.html#insert-java.lang.String-int-) * #### appendText [@Deprecated](../../java/lang/Deprecated.html "annotation in java.lang") public void appendText([String](../../java/lang/String.html "class in java.lang") str) Deprecated. * #### replaceRange public void replaceRange([String](../../java/lang/String.html "class in java.lang") str, int start, int end) Replaces text between the indicated start and end positions with the specified replacement text. The text at the end position will not be replaced. The text at the start position will be replaced (unless the start position is the same as the end position). The text position is zero-based. The inserted substring may be of a different length than the text it replaces. Note that passing `null` or inconsistent parameters is invalid and will result in unspecified behavior. Parameters: `str` \- the non-`null` text to use as the replacement `start` \- the start position `end` \- the end position Since: JDK1.1 See Also: [insert(java.lang.String, int)](../../java/awt/TextArea.html#insert-java.lang.String-int-) * #### replaceText [@Deprecated](../../java/lang/Deprecated.html "annotation in java.lang") public void replaceText([String](../../java/lang/String.html "class in java.lang") str, int start, int end) Deprecated. * #### getRows public int getRows() Returns the number of rows in the text area. Returns: the number of rows in the text area Since: JDK1 See Also: [setRows(int)](../../java/awt/TextArea.html#setRows-int-), [getColumns()](../../java/awt/TextArea.html#getColumns--) * #### setRows public void setRows(int rows) Sets the number of rows for this text area. Parameters: `rows` \- the number of rows Throws: `[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if the value supplied for `rows` is less than `0` Since: JDK1.1 See Also: [getRows()](../../java/awt/TextArea.html#getRows--), [setColumns(int)](../../java/awt/TextArea.html#setColumns-int-) * #### getColumns public int getColumns() Returns the number of columns in this text area. Returns: the number of columns in the text area See Also: [setColumns(int)](../../java/awt/TextArea.html#setColumns-int-), [getRows()](../../java/awt/TextArea.html#getRows--) * #### setColumns public void setColumns(int columns) Sets the number of columns for this text area. Parameters: `columns` \- the number of columns Throws: `[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if the value supplied for `columns` is less than `0` Since: JDK1.1 See Also: [getColumns()](../../java/awt/TextArea.html#getColumns--), [setRows(int)](../../java/awt/TextArea.html#setRows-int-) * #### getScrollbarVisibility public int getScrollbarVisibility() Returns 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](../../java/awt/TextArea.html#SCROLLBARS%5FBOTH), [SCROLLBARS\_VERTICAL\_ONLY](../../java/awt/TextArea.html#SCROLLBARS%5FVERTICAL%5FONLY), [SCROLLBARS\_HORIZONTAL\_ONLY](../../java/awt/TextArea.html#SCROLLBARS%5FHORIZONTAL%5FONLY), [SCROLLBARS\_NONE](../../java/awt/TextArea.html#SCROLLBARS%5FNONE), [TextArea(java.lang.String, int, int, int)](../../java/awt/TextArea.html#TextArea-java.lang.String-int-int-int-) * #### getPreferredSize public [Dimension](../../java/awt/Dimension.html "class in java.awt") 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 `columns` \- 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()](../../java/awt/Component.html#getPreferredSize--) * #### preferredSize [@Deprecated](../../java/lang/Deprecated.html "annotation in java.lang") public [Dimension](../../java/awt/Dimension.html "class in java.awt") preferredSize(int rows, int columns) Deprecated. * #### getPreferredSize public [Dimension](../../java/awt/Dimension.html "class in java.awt") getPreferredSize() Determines the preferred size of this text area. Overrides: `[getPreferredSize](../../java/awt/Component.html#getPreferredSize--)` in class `[Component](../../java/awt/Component.html "class in java.awt")` Returns: the preferred dimensions needed for this text area Since: JDK1.1 See Also: [Component.getPreferredSize()](../../java/awt/Component.html#getPreferredSize--) * #### preferredSize [@Deprecated](../../java/lang/Deprecated.html "annotation in java.lang") public [Dimension](../../java/awt/Dimension.html "class in java.awt") preferredSize() Deprecated. Overrides: `[preferredSize](../../java/awt/Component.html#preferredSize--)` in class `[Component](../../java/awt/Component.html "class in java.awt")` * #### getMinimumSize public [Dimension](../../java/awt/Dimension.html "class in java.awt") 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 `columns` \- 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()](../../java/awt/Component.html#getMinimumSize--) * #### minimumSize [@Deprecated](../../java/lang/Deprecated.html "annotation in java.lang") public [Dimension](../../java/awt/Dimension.html "class in java.awt") minimumSize(int rows, int columns) Deprecated. * #### getMinimumSize public [Dimension](../../java/awt/Dimension.html "class in java.awt") getMinimumSize() Determines the minimum size of this text area. Overrides: `[getMinimumSize](../../java/awt/Component.html#getMinimumSize--)` in class `[Component](../../java/awt/Component.html "class in java.awt")` Returns: the preferred dimensions needed for this text area Since: JDK1.1 See Also: [Component.getPreferredSize()](../../java/awt/Component.html#getPreferredSize--) * #### minimumSize [@Deprecated](../../java/lang/Deprecated.html "annotation in java.lang") public [Dimension](../../java/awt/Dimension.html "class in java.awt") minimumSize() Deprecated. Overrides: `[minimumSize](../../java/awt/Component.html#minimumSize--)` in class `[Component](../../java/awt/Component.html "class in java.awt")` * #### paramString protected [String](../../java/lang/String.html "class in java.lang") paramString() Returns a string representing the state of this `TextArea`. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be`null`. Overrides: `[paramString](../../java/awt/TextComponent.html#paramString--)` in class `[TextComponent](../../java/awt/TextComponent.html "class in java.awt")` Returns: the parameter string of this text area * #### getAccessibleContext public [AccessibleContext](../../javax/accessibility/AccessibleContext.html "class in javax.accessibility") getAccessibleContext() Returns 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. Specified by: `[getAccessibleContext](../../javax/accessibility/Accessible.html#getAccessibleContext--)` in interface `[Accessible](../../javax/accessibility/Accessible.html "interface in javax.accessibility")` Overrides: `[getAccessibleContext](../../java/awt/TextComponent.html#getAccessibleContext--)` in class `[TextComponent](../../java/awt/TextComponent.html "class in java.awt")` Returns: an `AccessibleAWTTextArea` that serves as the`AccessibleContext` of this `TextArea` Since: 1.3
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.