Class java.awt.TextArea
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.TextArea

Object
   |
   +----Component
           |
           +----TextComponent
                   |
                   +----java.awt.TextArea

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);
 

Version:
1.42, 08/13/98
Author:
Sami Shaio
Since:
JDK1.0

Variable Index

 o SCROLLBARS_BOTH
Create and display both vertical and horizontal scrollbars.
 o SCROLLBARS_HORIZONTAL_ONLY
Create and display horizontal scrollbar only.
 o SCROLLBARS_NONE
Do not create or display any scrollbars for the text area.
 o SCROLLBARS_VERTICAL_ONLY
Create and display vertical scrollbar only.

Constructor Index

 o java.awt.TextArea()
Constructs a new text area.
 o java.awt.TextArea(String)
Constructs a new text area with the specified text.
 o java.awt.TextArea(int, int)
Constructs a new empty TextArea with the specified number of rows and columns.
 o java.awt.TextArea(String, int, int)
Constructs a new text area with the specified text, and with the specified number of rows and columns.
 o java.awt.TextArea(String, int, int, int)
Constructs a new text area with the specified text, and with the rows, columns, and scroll bar visibility as specified.

Method Index

 o addNotify()
Creates the TextArea's peer.
 o append(String)
Appends the given text to the text area's current text.
 o appendText(String)
 o getColumns()
Gets the number of columns in this text area.
 o getMinimumSize(int, int)
Determines the minimum size of a text area with the specified number of rows and columns.
 o getMinimumSize()
Determines the minimum size of this text area.
 o getPreferredSize(int, int)
Determines the preferred size of a text area with the specified number of rows and columns.
 o getPreferredSize()
Determines the preferred size of this text area.
 o getRows()
Gets the number of rows in the text area.
 o getScrollbarVisibility()
Gets an enumerated value that indicates which scroll bars the text area uses.
 o insert(String, int)
Inserts the specified text at the specified position in this text area.
 o insertText(String, int)
 o minimumSize(int, int)
 o minimumSize()
 o paramString()
Returns the parameter string representing the state of this text area.
 o preferredSize(int, int)
 o preferredSize()
 o replaceRange(String, int, int)
Replaces text between the indicated start and end positions with the specified replacement text.
 o replaceText(String, int, int)
 o setColumns(int)
Sets the number of columns for this text area.
 o setRows(int)
Sets the number of rows for this text area.

Variables

 o SCROLLBARS_BOTH
public static final int SCROLLBARS_BOTH
Create and display both vertical and horizontal scrollbars.

Since: JDK1.1
 o SCROLLBARS_HORIZONTAL_ONLY
public static final int SCROLLBARS_HORIZONTAL_ONLY
Create and display horizontal scrollbar only.

Since: JDK1.1
 o SCROLLBARS_NONE
public static final int SCROLLBARS_NONE
Do not create or display any scrollbars for the text area.

Since: JDK1.1
 o SCROLLBARS_VERTICAL_ONLY
public static final int SCROLLBARS_VERTICAL_ONLY
Create and display vertical scrollbar only.

Since: JDK1.1

Constructors

 o TextArea
public TextArea()
Constructs a new text area. This text area is created with both vertical and horizontal scroll bars.

Since:
JDK1.0
 o TextArea
public TextArea(String text)
Constructs a new text area with the specified text. This text area is created with both vertical and horizontal scroll bars.

Parameters:
text - the text to be displayed.
Since:
JDK1.0
 o TextArea
public TextArea(int rows,
                int columns)
Constructs a new empty TextArea with the specified number of rows and columns.

Parameters:
rows - the number of rows
columns - the number of columns
 o TextArea
public 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. This text area is created with both vertical and horizontal scroll bars.

Parameters:
text - the text to be displayed.
rows - the number of rows.
columns - the number of columns.
Since:
JDK1.0
 o TextArea
public 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_NEITHER.

Parameters:
text - the text to be displayed.
rows - the number of rows.
columns - the number of columns.
scrollbars - a constant that determines what scrollbars are created to view the text area.
Since:
JDK1.1

Methods

 o 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 in class Component
 o append
public void append(String str)
Appends the given text to the text area's current text.

Parameters:
str - the text to append.
See Also:
insert
 o appendText
public synchronized void appendText(String str)
Note: appendText() is deprecated. As of JDK version 1.1, replaced by append(String).

 o getColumns
public int getColumns()
Gets the number of columns in this text area.

Returns:
the number of columns in the text area.
Since:
JDK1.0
See Also:
setColumns, getRows
 o getMinimumSize
public java.awt.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.
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:
getMinimumSize
 o getMinimumSize
public java.awt.Dimension getMinimumSize()
Determines the minimum size of this text area.

Returns:
the preferred dimensions needed for this text area.
Overrides:
getMinimumSize in class Component
Since:
JDK1.1
See Also:
getPreferredSize
 o getPreferredSize
public java.awt.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.
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:
getPreferredSize
 o getPreferredSize
public java.awt.Dimension getPreferredSize()
Determines the preferred size of this text area.

Returns:
the preferred dimensions needed for this text area.
Overrides:
getPreferredSize in class Component
Since:
JDK1.1
See Also:
getPreferredSize
 o getRows
public int getRows()
Gets the number of rows in the text area.

Returns:
the number of rows in the text area.
Since:
JDK1
See Also:
setRows, getColumns
 o getScrollbarVisibility
public int 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_NEITHER, TextArea(java.lang.String, int, int, int)
 o insert
public void 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:
setText, replaceRange, append
 o insertText
public synchronized void insertText(String str,
                                    int pos)
Note: insertText() is deprecated. As of JDK version 1.1, replaced by insert(String, int).

 o minimumSize
public java.awt.Dimension minimumSize(int rows,
                                      int columns)
Note: minimumSize() is deprecated. As of JDK version 1.1, replaced by getMinimumSize(int, int).

 o minimumSize
public java.awt.Dimension minimumSize()
Note: minimumSize() is deprecated. As of JDK version 1.1, replaced by getMinimumSize().

Overrides:
minimumSize in class Component
 o paramString
protected java.lang.String paramString()
Returns the parameter string representing the state of this text area. This string is useful for debugging.

Returns:
the parameter string of this text area.
Overrides:
paramString in class TextComponent
Since:
JDK1.0
 o preferredSize
public java.awt.Dimension preferredSize(int rows,
                                        int columns)
Note: preferredSize() is deprecated. As of JDK version 1.1, replaced by getPreferredSize(int, int).

 o preferredSize
public java.awt.Dimension preferredSize()
Note: preferredSize() is deprecated. As of JDK version 1.1, replaced by getPreferredSize().

Overrides:
preferredSize in class Component
 o replaceRange
public void 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
 o replaceText
public synchronized void replaceText(String str,
                                     int start,
                                     int end)
Note: replaceText() is deprecated. As of JDK version 1.1, replaced by replaceRange(String, int, int).

 o setColumns
public void 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 zero.
Since:
JDK1.1
See Also:
getColumns, setRows
 o setRows
public void 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 zero.
Since:
JDK1.1
See Also:
getRows, setColumns

All Packages  Class Hierarchy  This Package  Previous  Next  Index