TextArea (Java SE 15 & JDK 15) (original) (raw)
All Implemented Interfaces:
[ImageObserver](image/ImageObserver.html "interface in java.awt.image")
, [MenuContainer](MenuContainer.html "interface in java.awt")
, [Serializable](../../../java.base/java/io/Serializable.html "interface in java.io")
, [Accessible](../../javax/accessibility/Accessible.html "interface in javax.accessibility")
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:
1.0
See Also:
Nested Class Summary
Nested Classes
Modifier and Type | Class | Description |
---|---|---|
protected class | TextArea.AccessibleAWTTextArea | This class implements accessibility support for theTextArea class. |
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. |
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
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 declared in class java.awt.TextComponent
[addTextListener](TextComponent.html#addTextListener%28java.awt.event.TextListener%29), [enableInputMethods](TextComponent.html#enableInputMethods%28boolean%29), [getBackground](TextComponent.html#getBackground%28%29), [getCaretPosition](TextComponent.html#getCaretPosition%28%29), [getListeners](TextComponent.html#getListeners%28java.lang.Class%29), [getSelectedText](TextComponent.html#getSelectedText%28%29), [getSelectionEnd](TextComponent.html#getSelectionEnd%28%29), [getSelectionStart](TextComponent.html#getSelectionStart%28%29), [getText](TextComponent.html#getText%28%29), [getTextListeners](TextComponent.html#getTextListeners%28%29), [isEditable](TextComponent.html#isEditable%28%29), [processEvent](TextComponent.html#processEvent%28java.awt.AWTEvent%29), [processTextEvent](TextComponent.html#processTextEvent%28java.awt.event.TextEvent%29), [removeNotify](TextComponent.html#removeNotify%28%29), [removeTextListener](TextComponent.html#removeTextListener%28java.awt.event.TextListener%29), [select](TextComponent.html#select%28int,int%29), [selectAll](TextComponent.html#selectAll%28%29), [setBackground](TextComponent.html#setBackground%28java.awt.Color%29), [setCaretPosition](TextComponent.html#setCaretPosition%28int%29), [setEditable](TextComponent.html#setEditable%28boolean%29), [setSelectionEnd](TextComponent.html#setSelectionEnd%28int%29), [setSelectionStart](TextComponent.html#setSelectionStart%28int%29), [setText](TextComponent.html#setText%28java.lang.String%29)
Methods declared in class java.awt.Component
[action](Component.html#action%28java.awt.Event,java.lang.Object%29), [add](Component.html#add%28java.awt.PopupMenu%29), [addComponentListener](Component.html#addComponentListener%28java.awt.event.ComponentListener%29), [addFocusListener](Component.html#addFocusListener%28java.awt.event.FocusListener%29), [addHierarchyBoundsListener](Component.html#addHierarchyBoundsListener%28java.awt.event.HierarchyBoundsListener%29), [addHierarchyListener](Component.html#addHierarchyListener%28java.awt.event.HierarchyListener%29), [addInputMethodListener](Component.html#addInputMethodListener%28java.awt.event.InputMethodListener%29), [addKeyListener](Component.html#addKeyListener%28java.awt.event.KeyListener%29), [addMouseListener](Component.html#addMouseListener%28java.awt.event.MouseListener%29), [addMouseMotionListener](Component.html#addMouseMotionListener%28java.awt.event.MouseMotionListener%29), [addMouseWheelListener](Component.html#addMouseWheelListener%28java.awt.event.MouseWheelListener%29), [addPropertyChangeListener](Component.html#addPropertyChangeListener%28java.beans.PropertyChangeListener%29), [addPropertyChangeListener](Component.html#addPropertyChangeListener%28java.lang.String,java.beans.PropertyChangeListener%29), [applyComponentOrientation](Component.html#applyComponentOrientation%28java.awt.ComponentOrientation%29), [areFocusTraversalKeysSet](Component.html#areFocusTraversalKeysSet%28int%29), [bounds](Component.html#bounds%28%29), [checkImage](Component.html#checkImage%28java.awt.Image,int,int,java.awt.image.ImageObserver%29), [checkImage](Component.html#checkImage%28java.awt.Image,java.awt.image.ImageObserver%29), [coalesceEvents](Component.html#coalesceEvents%28java.awt.AWTEvent,java.awt.AWTEvent%29), [contains](Component.html#contains%28int,int%29), [contains](Component.html#contains%28java.awt.Point%29), [createImage](Component.html#createImage%28int,int%29), [createImage](Component.html#createImage%28java.awt.image.ImageProducer%29), [createVolatileImage](Component.html#createVolatileImage%28int,int%29), [createVolatileImage](Component.html#createVolatileImage%28int,int,java.awt.ImageCapabilities%29), [deliverEvent](Component.html#deliverEvent%28java.awt.Event%29), [disable](Component.html#disable%28%29), [disableEvents](Component.html#disableEvents%28long%29), [dispatchEvent](Component.html#dispatchEvent%28java.awt.AWTEvent%29), [doLayout](Component.html#doLayout%28%29), [enable](Component.html#enable%28%29), [enable](Component.html#enable%28boolean%29), [enableEvents](Component.html#enableEvents%28long%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,boolean,boolean%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,byte,byte%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,char,char%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,double,double%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,float,float%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,int,int%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,long,long%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,short,short%29), [firePropertyChange](Component.html#firePropertyChange%28java.lang.String,java.lang.Object,java.lang.Object%29), [getAlignmentX](Component.html#getAlignmentX%28%29), [getAlignmentY](Component.html#getAlignmentY%28%29), [getBaseline](Component.html#getBaseline%28int,int%29), [getBaselineResizeBehavior](Component.html#getBaselineResizeBehavior%28%29), [getBounds](Component.html#getBounds%28%29), [getBounds](Component.html#getBounds%28java.awt.Rectangle%29), [getColorModel](Component.html#getColorModel%28%29), [getComponentAt](Component.html#getComponentAt%28int,int%29), [getComponentAt](Component.html#getComponentAt%28java.awt.Point%29), [getComponentListeners](Component.html#getComponentListeners%28%29), [getComponentOrientation](Component.html#getComponentOrientation%28%29), [getCursor](Component.html#getCursor%28%29), [getDropTarget](Component.html#getDropTarget%28%29), [getFocusCycleRootAncestor](Component.html#getFocusCycleRootAncestor%28%29), [getFocusListeners](Component.html#getFocusListeners%28%29), [getFocusTraversalKeys](Component.html#getFocusTraversalKeys%28int%29), [getFocusTraversalKeysEnabled](Component.html#getFocusTraversalKeysEnabled%28%29), [getFont](Component.html#getFont%28%29), [getFontMetrics](Component.html#getFontMetrics%28java.awt.Font%29), [getForeground](Component.html#getForeground%28%29), [getGraphics](Component.html#getGraphics%28%29), [getGraphicsConfiguration](Component.html#getGraphicsConfiguration%28%29), [getHeight](Component.html#getHeight%28%29), [getHierarchyBoundsListeners](Component.html#getHierarchyBoundsListeners%28%29), [getHierarchyListeners](Component.html#getHierarchyListeners%28%29), [getIgnoreRepaint](Component.html#getIgnoreRepaint%28%29), [getInputContext](Component.html#getInputContext%28%29), [getInputMethodListeners](Component.html#getInputMethodListeners%28%29), [getInputMethodRequests](Component.html#getInputMethodRequests%28%29), [getKeyListeners](Component.html#getKeyListeners%28%29), [getLocale](Component.html#getLocale%28%29), [getLocation](Component.html#getLocation%28%29), [getLocation](Component.html#getLocation%28java.awt.Point%29), [getLocationOnScreen](Component.html#getLocationOnScreen%28%29), [getMaximumSize](Component.html#getMaximumSize%28%29), [getMouseListeners](Component.html#getMouseListeners%28%29), [getMouseMotionListeners](Component.html#getMouseMotionListeners%28%29), [getMousePosition](Component.html#getMousePosition%28%29), [getMouseWheelListeners](Component.html#getMouseWheelListeners%28%29), [getName](Component.html#getName%28%29), [getParent](Component.html#getParent%28%29), [getPropertyChangeListeners](Component.html#getPropertyChangeListeners%28%29), [getPropertyChangeListeners](Component.html#getPropertyChangeListeners%28java.lang.String%29), [getSize](Component.html#getSize%28%29), [getSize](Component.html#getSize%28java.awt.Dimension%29), [getToolkit](Component.html#getToolkit%28%29), [getTreeLock](Component.html#getTreeLock%28%29), [getWidth](Component.html#getWidth%28%29), [getX](Component.html#getX%28%29), [getY](Component.html#getY%28%29), [gotFocus](Component.html#gotFocus%28java.awt.Event,java.lang.Object%29), [handleEvent](Component.html#handleEvent%28java.awt.Event%29), [hasFocus](Component.html#hasFocus%28%29), [hide](Component.html#hide%28%29), [imageUpdate](Component.html#imageUpdate%28java.awt.Image,int,int,int,int,int%29), [inside](Component.html#inside%28int,int%29), [invalidate](Component.html#invalidate%28%29), [isBackgroundSet](Component.html#isBackgroundSet%28%29), [isCursorSet](Component.html#isCursorSet%28%29), [isDisplayable](Component.html#isDisplayable%28%29), [isDoubleBuffered](Component.html#isDoubleBuffered%28%29), [isEnabled](Component.html#isEnabled%28%29), [isFocusable](Component.html#isFocusable%28%29), [isFocusCycleRoot](Component.html#isFocusCycleRoot%28java.awt.Container%29), [isFocusOwner](Component.html#isFocusOwner%28%29), [isFocusTraversable](Component.html#isFocusTraversable%28%29), [isFontSet](Component.html#isFontSet%28%29), [isForegroundSet](Component.html#isForegroundSet%28%29), [isLightweight](Component.html#isLightweight%28%29), [isMaximumSizeSet](Component.html#isMaximumSizeSet%28%29), [isMinimumSizeSet](Component.html#isMinimumSizeSet%28%29), [isOpaque](Component.html#isOpaque%28%29), [isPreferredSizeSet](Component.html#isPreferredSizeSet%28%29), [isShowing](Component.html#isShowing%28%29), [isValid](Component.html#isValid%28%29), [isVisible](Component.html#isVisible%28%29), [keyDown](Component.html#keyDown%28java.awt.Event,int%29), [keyUp](Component.html#keyUp%28java.awt.Event,int%29), [layout](Component.html#layout%28%29), [list](Component.html#list%28%29), [list](Component.html#list%28java.io.PrintStream%29), [list](Component.html#list%28java.io.PrintStream,int%29), [list](Component.html#list%28java.io.PrintWriter%29), [list](Component.html#list%28java.io.PrintWriter,int%29), [locate](Component.html#locate%28int,int%29), [location](Component.html#location%28%29), [lostFocus](Component.html#lostFocus%28java.awt.Event,java.lang.Object%29), [mouseDown](Component.html#mouseDown%28java.awt.Event,int,int%29), [mouseDrag](Component.html#mouseDrag%28java.awt.Event,int,int%29), [mouseEnter](Component.html#mouseEnter%28java.awt.Event,int,int%29), [mouseExit](Component.html#mouseExit%28java.awt.Event,int,int%29), [mouseMove](Component.html#mouseMove%28java.awt.Event,int,int%29), [mouseUp](Component.html#mouseUp%28java.awt.Event,int,int%29), [move](Component.html#move%28int,int%29), [nextFocus](Component.html#nextFocus%28%29), [paint](Component.html#paint%28java.awt.Graphics%29), [paintAll](Component.html#paintAll%28java.awt.Graphics%29), [postEvent](Component.html#postEvent%28java.awt.Event%29), [prepareImage](Component.html#prepareImage%28java.awt.Image,int,int,java.awt.image.ImageObserver%29), [prepareImage](Component.html#prepareImage%28java.awt.Image,java.awt.image.ImageObserver%29), [print](Component.html#print%28java.awt.Graphics%29), [printAll](Component.html#printAll%28java.awt.Graphics%29), [processComponentEvent](Component.html#processComponentEvent%28java.awt.event.ComponentEvent%29), [processFocusEvent](Component.html#processFocusEvent%28java.awt.event.FocusEvent%29), [processHierarchyBoundsEvent](Component.html#processHierarchyBoundsEvent%28java.awt.event.HierarchyEvent%29), [processHierarchyEvent](Component.html#processHierarchyEvent%28java.awt.event.HierarchyEvent%29), [processInputMethodEvent](Component.html#processInputMethodEvent%28java.awt.event.InputMethodEvent%29), [processKeyEvent](Component.html#processKeyEvent%28java.awt.event.KeyEvent%29), [processMouseEvent](Component.html#processMouseEvent%28java.awt.event.MouseEvent%29), [processMouseMotionEvent](Component.html#processMouseMotionEvent%28java.awt.event.MouseEvent%29), [processMouseWheelEvent](Component.html#processMouseWheelEvent%28java.awt.event.MouseWheelEvent%29), [remove](Component.html#remove%28java.awt.MenuComponent%29), [removeComponentListener](Component.html#removeComponentListener%28java.awt.event.ComponentListener%29), [removeFocusListener](Component.html#removeFocusListener%28java.awt.event.FocusListener%29), [removeHierarchyBoundsListener](Component.html#removeHierarchyBoundsListener%28java.awt.event.HierarchyBoundsListener%29), [removeHierarchyListener](Component.html#removeHierarchyListener%28java.awt.event.HierarchyListener%29), [removeInputMethodListener](Component.html#removeInputMethodListener%28java.awt.event.InputMethodListener%29), [removeKeyListener](Component.html#removeKeyListener%28java.awt.event.KeyListener%29), [removeMouseListener](Component.html#removeMouseListener%28java.awt.event.MouseListener%29), [removeMouseMotionListener](Component.html#removeMouseMotionListener%28java.awt.event.MouseMotionListener%29), [removeMouseWheelListener](Component.html#removeMouseWheelListener%28java.awt.event.MouseWheelListener%29), [removePropertyChangeListener](Component.html#removePropertyChangeListener%28java.beans.PropertyChangeListener%29), [removePropertyChangeListener](Component.html#removePropertyChangeListener%28java.lang.String,java.beans.PropertyChangeListener%29), [repaint](Component.html#repaint%28%29), [repaint](Component.html#repaint%28int,int,int,int%29), [repaint](Component.html#repaint%28long%29), [repaint](Component.html#repaint%28long,int,int,int,int%29), [requestFocus](Component.html#requestFocus%28%29), [requestFocus](Component.html#requestFocus%28boolean%29), [requestFocus](Component.html#requestFocus%28boolean,java.awt.event.FocusEvent.Cause%29), [requestFocus](Component.html#requestFocus%28java.awt.event.FocusEvent.Cause%29), [requestFocusInWindow](Component.html#requestFocusInWindow%28%29), [requestFocusInWindow](Component.html#requestFocusInWindow%28boolean%29), [requestFocusInWindow](Component.html#requestFocusInWindow%28java.awt.event.FocusEvent.Cause%29), [reshape](Component.html#reshape%28int,int,int,int%29), [resize](Component.html#resize%28int,int%29), [resize](Component.html#resize%28java.awt.Dimension%29), [revalidate](Component.html#revalidate%28%29), [setBounds](Component.html#setBounds%28int,int,int,int%29), [setBounds](Component.html#setBounds%28java.awt.Rectangle%29), [setComponentOrientation](Component.html#setComponentOrientation%28java.awt.ComponentOrientation%29), [setCursor](Component.html#setCursor%28java.awt.Cursor%29), [setDropTarget](Component.html#setDropTarget%28java.awt.dnd.DropTarget%29), [setEnabled](Component.html#setEnabled%28boolean%29), [setFocusable](Component.html#setFocusable%28boolean%29), [setFocusTraversalKeys](Component.html#setFocusTraversalKeys%28int,java.util.Set%29), [setFocusTraversalKeysEnabled](Component.html#setFocusTraversalKeysEnabled%28boolean%29), [setFont](Component.html#setFont%28java.awt.Font%29), [setForeground](Component.html#setForeground%28java.awt.Color%29), [setIgnoreRepaint](Component.html#setIgnoreRepaint%28boolean%29), [setLocale](Component.html#setLocale%28java.util.Locale%29), [setLocation](Component.html#setLocation%28int,int%29), [setLocation](Component.html#setLocation%28java.awt.Point%29), [setMaximumSize](Component.html#setMaximumSize%28java.awt.Dimension%29), [setMinimumSize](Component.html#setMinimumSize%28java.awt.Dimension%29), [setMixingCutoutShape](Component.html#setMixingCutoutShape%28java.awt.Shape%29), [setName](Component.html#setName%28java.lang.String%29), [setPreferredSize](Component.html#setPreferredSize%28java.awt.Dimension%29), [setSize](Component.html#setSize%28int,int%29), [setSize](Component.html#setSize%28java.awt.Dimension%29), [setVisible](Component.html#setVisible%28boolean%29), [show](Component.html#show%28%29), [show](Component.html#show%28boolean%29), [size](Component.html#size%28%29), [toString](Component.html#toString%28%29), [transferFocus](Component.html#transferFocus%28%29), [transferFocusBackward](Component.html#transferFocusBackward%28%29), [transferFocusUpCycle](Component.html#transferFocusUpCycle%28%29), [update](Component.html#update%28java.awt.Graphics%29), [validate](Component.html#validate%28%29)
Field Details
SCROLLBARS_BOTH
public static final int SCROLLBARS_BOTH
Create and display both vertical and horizontal scrollbars.
Since:
1.1
See Also:
Constant Field ValuesSCROLLBARS_VERTICAL_ONLY
public static final int SCROLLBARS_VERTICAL_ONLY
Create and display vertical scrollbar only.
Since:
1.1
See Also:
Constant Field ValuesSCROLLBARS_HORIZONTAL_ONLY
public static final int SCROLLBARS_HORIZONTAL_ONLY
Create and display horizontal scrollbar only.
Since:
1.1
See Also:
Constant Field ValuesSCROLLBARS_NONE
public static final int SCROLLBARS_NONE
Do not create or display any scrollbars for the text area.
Since:
1.1
See Also:
Constant Field ValuesConstructor Details
TextArea
Constructs a new text area with the empty string as text. This text area is created with scrollbar visibility equal toSCROLLBARS_BOTH, so both vertical and horizontal scrollbars will be visible for this text area.
Throws:
[HeadlessException](HeadlessException.html "class in java.awt")
- ifGraphicsEnvironment.isHeadless
returns true
See Also:
GraphicsEnvironment.isHeadless()TextArea
Constructs a new text area with the specified text. This text area is created with scrollbar visibility equal toSCROLLBARS_BOTH, so both vertical and horizontal scrollbars will be visible for this text area.
Parameters:
text
- the text to be displayed; iftext
isnull
, the empty string""
will be displayed
Throws:
[HeadlessException](HeadlessException.html "class in java.awt")
- ifGraphicsEnvironment.isHeadless
returns true
See Also:
GraphicsEnvironment.isHeadless()TextArea
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, 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](HeadlessException.html "class in java.awt")
- ifGraphicsEnvironment.isHeadless
returns true
See Also:
GraphicsEnvironment.isHeadless()TextArea
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; iftext
isnull
, the empty string""
will be displayed
rows
- the number of rows
columns
- the number of columns
Throws:
[HeadlessException](HeadlessException.html "class in java.awt")
- ifGraphicsEnvironment.isHeadless
returns true
See Also:
GraphicsEnvironment.isHeadless()TextArea
public TextArea(String text, int rows, int columns, int scrollbars) throws HeadlessException
Constructs a new text area with the specified text, and with the rows, columns, and scroll bar visibility as specified. AllTextArea
constructors defer to this one.
TheTextArea
class defines several constants that can be supplied as values for thescrollbars
argument:
*SCROLLBARS_BOTH
,
*SCROLLBARS_VERTICAL_ONLY
,
*SCROLLBARS_HORIZONTAL_ONLY
,
*SCROLLBARS_NONE
.
Any other value for thescrollbars
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; iftext
isnull
, the empty string""
will be displayed
rows
- the number of rows; ifrows
is less than0
,rows
is set to0
columns
- the number of columns; ifcolumns
is less than0
,columns
is set to0
scrollbars
- a constant that determines what scrollbars are created to view the text area
Throws:
[HeadlessException](HeadlessException.html "class in java.awt")
- ifGraphicsEnvironment.isHeadless
returns true
Since:
1.1
See Also:
GraphicsEnvironment.isHeadless()Method Details
addNotify
public void addNotify()
Creates theTextArea
's peer. The peer allows us to modify the appearance of theTextArea
without changing any of its functionality.
Overrides:
[addNotify](TextComponent.html#addNotify%28%29)
in class[TextComponent](TextComponent.html "class in java.awt")
See Also:
TextComponent.removeNotify()insert
public void insert(String str, int pos)
Inserts the specified text at the specified position in this text area.
Note that passingnull
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:
1.1
See Also:
TextComponent.setText(java.lang.String), replaceRange(java.lang.String, int, int), append(java.lang.String)insertText
Inserts the specified text at the specified position in this text area.
Parameters:
str
- the non-null
text to insert
pos
- the position at which to insertappend
public void append(String str)
Appends the given text to the text area's current text.
Note that passingnull
or inconsistent parameters is invalid and will result in unspecified behavior.
Parameters:
str
- the non-null
text to append
Since:
1.1
See Also:
insert(java.lang.String, int)appendText
Appends the given text to the text area's current text.
Parameters:
str
- the text to appendreplaceRange
public void replaceRange(String 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 passingnull
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:
1.1
See Also:
insert(java.lang.String, int)replaceText
Replaces a range of characters between the indicated start and end positions with the specified replacement text (the text at the end position will not be replaced).
Parameters:
str
- the non-null
text to use as the replacement
start
- the start position
end
- the end positiongetRows
public int getRows()
Returns the number of rows in the text area.
Returns:
the number of rows in the text area
Since:
1.0
See Also:
setRows(int), 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.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if the value supplied forrows
is less than0
Since:
1.1
See Also:
getRows(), 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), 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.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if the value supplied forcolumns
is less than0
Since:
1.1
See Also:
getColumns(), setRows(int)getScrollbarVisibility
public int getScrollbarVisibility()
Returns an enumerated value that indicates which scroll bars the text area uses.
TheTextArea
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:
1.1
See Also:
SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, TextArea(java.lang.String, int, int, int)getPreferredSize
public Dimension 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:
1.1
See Also:
Component.getPreferredSize()preferredSize
Determines the preferred size of the 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 needed for the text areagetPreferredSize
Determines the preferred size of this text area.
Overrides:
[getPreferredSize](Component.html#getPreferredSize%28%29)
in class[Component](Component.html "class in java.awt")
Returns:
the preferred dimensions needed for this text area
Since:
1.1
See Also:
Component.getPreferredSize()preferredSize
Description copied from class:
[Component](Component.html#preferredSize%28%29)
Returns the component's preferred size.
Overrides:
[preferredSize](Component.html#preferredSize%28%29)
in class[Component](Component.html "class in java.awt")
Returns:
the component's preferred sizegetMinimumSize
public Dimension 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:
1.1
See Also:
Component.getMinimumSize()minimumSize
Determines the minimum size of the text area with the specified number of rows and columns.
Parameters:
rows
- the number of rows
columns
- the number of columns
Returns:
the minimum size for the text areagetMinimumSize
Determines the minimum size of this text area.
Overrides:
[getMinimumSize](Component.html#getMinimumSize%28%29)
in class[Component](Component.html "class in java.awt")
Returns:
the preferred dimensions needed for this text area
Since:
1.1
See Also:
Component.getPreferredSize()minimumSize
Description copied from class:
[Component](Component.html#minimumSize%28%29)
Returns the minimum size of this component.
Overrides:
[minimumSize](Component.html#minimumSize%28%29)
in class[Component](Component.html "class in java.awt")
Returns:
the minimum size of this componentparamString
protected String paramString()
Returns a string representing the state of thisTextArea
. 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 benull
.
Overrides:
[paramString](TextComponent.html#paramString%28%29)
in class[TextComponent](TextComponent.html "class in java.awt")
Returns:
the parameter string of this text areagetAccessibleContext
Returns the
AccessibleContext
associated with thisTextArea
. For text areas, theAccessibleContext
takes the form of anAccessibleAWTTextArea
. A newAccessibleAWTTextArea
instance is created if necessary.
Specified by:
[getAccessibleContext](../../javax/accessibility/Accessible.html#getAccessibleContext%28%29)
in interface[Accessible](../../javax/accessibility/Accessible.html "interface in javax.accessibility")
Overrides:
[getAccessibleContext](TextComponent.html#getAccessibleContext%28%29)
in class[TextComponent](TextComponent.html "class in java.awt")
Returns:
anAccessibleAWTTextArea
that serves as theAccessibleContext
of thisTextArea
Since:
1.3