当前页面:
在线文档首页 >
JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
Class java.awt.TextArea - JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.TextArea
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.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);
-
SCROLLBARS_BOTH
- Create and display both vertical and horizontal scrollbars.
-
SCROLLBARS_HORIZONTAL_ONLY
- Create and display horizontal scrollbar only.
-
SCROLLBARS_NONE
- Do not create or display any scrollbars for the text area.
-
SCROLLBARS_VERTICAL_ONLY
- Create and display vertical scrollbar only.
-
TextArea()
- Constructs a new text area.
-
TextArea(int, int)
- Constructs a new empty TextArea with the specified number of
rows and columns.
-
TextArea(String)
- Constructs a new text area with the specified text.
-
TextArea(String, int, int)
- Constructs a new text area with the specified text,
and with the specified number of rows and columns.
-
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.
-
addNotify()
- Creates the TextArea's peer.
-
append(String)
- Appends the given text to the text area's current text.
-
appendText(String)
-
Deprecated.
-
getColumns()
- Gets the number of columns in this text area.
-
getMinimumSize()
- Determines the minimum size of this text area.
-
getMinimumSize(int, int)
- Determines the minimum size of a text area with the specified
number of rows and columns.
-
getPreferredSize()
- Determines the preferred size of this text area.
-
getPreferredSize(int, int)
- Determines the preferred size of a text area with the specified
number of rows and columns.
-
getRows()
- Gets the number of rows in the text area.
-
getScrollbarVisibility()
- Gets an enumerated value that indicates which scroll bars
the text area uses.
-
insert(String, int)
- Inserts the specified text at the specified position
in this text area.
-
insertText(String, int)
-
Deprecated.
-
minimumSize()
-
Deprecated.
-
minimumSize(int, int)
-
Deprecated.
-
paramString()
- Returns the parameter string representing the state of
this text area.
-
preferredSize()
-
Deprecated.
-
preferredSize(int, int)
-
Deprecated.
-
replaceRange(String, int, int)
- Replaces text between the indicated start and end positions
with the specified replacement text.
-
replaceText(String, int, int)
-
Deprecated.
-
setColumns(int)
- Sets the number of columns for this text area.
-
setRows(int)
- Sets the number of rows for this text area.
SCROLLBARS_BOTH
public static final int SCROLLBARS_BOTH
- Create and display both vertical and horizontal scrollbars.
SCROLLBARS_VERTICAL_ONLY
public static final int SCROLLBARS_VERTICAL_ONLY
- Create and display vertical scrollbar only.
SCROLLBARS_HORIZONTAL_ONLY
public static final int SCROLLBARS_HORIZONTAL_ONLY
- Create and display horizontal scrollbar only.
SCROLLBARS_NONE
public static final int SCROLLBARS_NONE
- Do not create or display any scrollbars for the text area.
TextArea
public TextArea()
- Constructs a new text area.
This text area is created with both vertical and
horizontal scroll bars.
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.
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
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.
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.
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
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.
- See Also:
- setText, replaceRange, append
insertText
public synchronized void insertText(String str,
int pos)
- Note: insertText() is deprecated.
As of JDK version 1.1,
replaced by
insert(String, int)
.
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
appendText
public synchronized void appendText(String str)
- Note: appendText() is deprecated.
As of JDK version 1.1,
replaced by
append(String)
.
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.
- See Also:
- insert
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)
.
getRows
public int getRows()
- Gets the number of rows in the text area.
- Returns:
- the number of rows in the text area.
- See Also:
- setRows, getColumns
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.
- See Also:
- getRows, setColumns
getColumns
public int getColumns()
- Gets the number of columns in this text area.
- Returns:
- the number of columns in the text area.
- See Also:
- setColumns, getRows
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.
- See Also:
- getColumns, setRows
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.
- See Also:
- SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NEITHER, TextArea
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.
- cols - the number of columns.
- Returns:
- the preferred dimensions required to display
the text area with the specified
number of rows and columns.
- See Also:
- getPreferredSize
preferredSize
public Dimension preferredSize(int rows,
int columns)
- Note: preferredSize() is deprecated.
As of JDK version 1.1,
replaced by
getPreferredSize(int, int)
.
getPreferredSize
public Dimension getPreferredSize()
- Determines the preferred size of this text area.
- Returns:
- the preferred dimensions needed for this text area.
- Overrides:
- getPreferredSize in class Component
- See Also:
- getPreferredSize
preferredSize
public Dimension preferredSize()
- Note: preferredSize() is deprecated.
As of JDK version 1.1,
replaced by
getPreferredSize()
.
- Overrides:
- preferredSize in class Component
getMinimumSize
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.
- cols - the number of columns.
- Returns:
- the minimum dimensions required to display
the text area with the specified
number of rows and columns.
- See Also:
- getMinimumSize
minimumSize
public Dimension minimumSize(int rows,
int columns)
- Note: minimumSize() is deprecated.
As of JDK version 1.1,
replaced by
getMinimumSize(int, int)
.
getMinimumSize
public Dimension getMinimumSize()
- Determines the minimum size of this text area.
- Returns:
- the preferred dimensions needed for this text area.
- Overrides:
- getMinimumSize in class Component
- See Also:
- getPreferredSize
minimumSize
public Dimension minimumSize()
- Note: minimumSize() is deprecated.
As of JDK version 1.1,
replaced by
getMinimumSize()
.
- Overrides:
- minimumSize in class Component
paramString
protected 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
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.