|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.TextComponent java.awt.TextArea
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);
Nested Class Summary | |
protected class |
TextArea.AccessibleAWTTextArea
This class implements accessibility support for the TextArea class. |
Nested classes inherited from class java.awt.TextComponent |
TextComponent.AccessibleAWTTextComponent |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.AWTTreeLock, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
private static Set |
backwardTraversalKeys
Cache the Sets of forward and backward traversal keys so we need not look them up each time. |
private static String |
base
|
(package private) int |
columns
The number of columns in the TextArea .
|
private static Set |
forwardTraversalKeys
Cache the Sets of forward and backward traversal keys so we need not look them up each time. |
private static int |
nameCounter
|
(package private) int |
rows
The number of rows in the TextArea .
|
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. |
private int |
scrollbarVisibility
Determines which scrollbars are created for the text area. |
private static long |
serialVersionUID
|
private int |
textAreaSerializedDataVersion
The textArea Serialized Data Version. |
Fields inherited from class java.awt.TextComponent |
backgroundSetByClientCode, editable, selectionEnd, selectionStart, text, textListener |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
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 | |
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. As of JDK version 1.1, replaced by append(String) . |
(package private) String |
constructComponentName()
Construct a name for this component. |
javax.accessibility.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. |
private static void |
initIDs()
Initialize JNI field and method ids |
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. As of JDK version 1.1, replaced by insert(String, int) . |
Dimension |
minimumSize()
Deprecated. As of JDK version 1.1, replaced by getMinimumSize() . |
Dimension |
minimumSize(int rows,
int columns)
Deprecated. As of JDK version 1.1, replaced by getMinimumSize(int, int) . |
protected String |
paramString()
Returns a string representing the state of this TextArea .
|
Dimension |
preferredSize()
Deprecated. As of JDK version 1.1, replaced by getPreferredSize() . |
Dimension |
preferredSize(int rows,
int columns)
Deprecated. As of JDK version 1.1, replaced by getPreferredSize(int, int) . |
private void |
readObject(ObjectInputStream s)
Read the ObjectInputStream. |
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. As of JDK version 1.1, replaced by replaceRange(String, int, int) . |
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.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
int rows
TextArea
.
This parameter will determine the text area's height.
Guaranteed to be non-negative.
getRows()
,
setRows(int)
int columns
TextArea
.
A column is an approximate average character
width that is platform-dependent.
This parameter will determine the text area's width.
Guaranteed to be non-negative.
setColumns(int)
,
getColumns()
private static final String base
private static int nameCounter
public static final int SCROLLBARS_BOTH
public static final int SCROLLBARS_VERTICAL_ONLY
public static final int SCROLLBARS_HORIZONTAL_ONLY
public static final int SCROLLBARS_NONE
private int scrollbarVisibility
SCROLLBARS_BOTH
= both scrollbars.SCROLLBARS_HORIZONTAL_ONLY
= Horizontal bar only.SCROLLBARS_VERTICAL_ONLY
= Vertical bar only.SCROLLBARS_NONE
= No scrollbars.
getScrollbarVisibility()
private static Set forwardTraversalKeys
private static Set backwardTraversalKeys
private static final long serialVersionUID
private int textAreaSerializedDataVersion
Constructor Detail |
public TextArea() throws HeadlessException
SCROLLBARS_BOTH
, so both vertical and horizontal
scrollbars will be visible for this text area.
HeadlessException
- if
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()
public TextArea(String text) throws HeadlessException
SCROLLBARS_BOTH
, so both vertical and horizontal
scrollbars will be visible for this text area.
text
- the text to be displayed; if
text
is null
, the empty
string ""
will be displayed
HeadlessException
- if
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()
public TextArea(int rows, int columns) throws HeadlessException
SCROLLBARS_BOTH
, so both
vertical and horizontal scrollbars will be visible for this
text area.
rows
- the number of rowscolumns
- the number of columns
HeadlessException
- if
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()
public TextArea(String text, int rows, int columns) throws HeadlessException
SCROLLBARS_BOTH
, so both
vertical and horizontal scrollbars will be visible for this
text area.
text
- the text to be displayed; if
text
is null
, the empty
string ""
will be displayedrows
- the number of rowscolumns
- the number of columns
HeadlessException
- if
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()
public TextArea(String text, int rows, int columns, int scrollbars) throws HeadlessException
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
.
scrollbars
argument is invalid and will result in
this text area being created with scrollbar visibility equal to
the default value of SCROLLBARS_BOTH
.
text
- the text to be displayed; if
text
is null
, the empty
string ""
will be displayedrows
- 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
HeadlessException
- if
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()
Method Detail |
private static void initIDs()
String constructComponentName()
getName
when the name is null
.
constructComponentName
in class Component
public void addNotify()
TextArea
's peer. The peer allows us to modify
the appearance of the TextArea
without changing any of its
functionality.
addNotify
in class TextComponent
TextComponent.removeNotify()
public void insert(String str, int pos)
Note that passing null
or inconsistent
parameters is invalid and will result in unspecified
behavior.
str
- the non-null
text to insertpos
- the position at which to insertTextComponent.setText(java.lang.String)
,
replaceRange(java.lang.String, int, int)
,
append(java.lang.String)
public void insertText(String str, int pos)
insert(String, int)
.
public void append(String str)
Note that passing null
or inconsistent
parameters is invalid and will result in unspecified
behavior.
str
- the non-null
text to appendinsert(java.lang.String, int)
public void appendText(String str)
append(String)
.
public void replaceRange(String str, int start, int end)
Note that passing null
or inconsistent
parameters is invalid and will result in unspecified
behavior.
str
- the non-null
text to use as
the replacementstart
- the start positionend
- the end positioninsert(java.lang.String, int)
public void replaceText(String str, int start, int end)
replaceRange(String, int, int)
.
public int getRows()
setRows(int)
,
getColumns()
public void setRows(int rows)
rows
- the number of rows
IllegalArgumentException
- if the value
supplied for rows
is less than 0
getRows()
,
setColumns(int)
public int getColumns()
setColumns(int)
,
getRows()
public void setColumns(int columns)
columns
- the number of columns
IllegalArgumentException
- if the value
supplied for columns
is less than 0
getColumns()
,
setRows(int)
public int getScrollbarVisibility()
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.
SCROLLBARS_BOTH
,
SCROLLBARS_VERTICAL_ONLY
,
SCROLLBARS_HORIZONTAL_ONLY
,
SCROLLBARS_NONE
,
TextArea(java.lang.String, int, int, int)
public Dimension getPreferredSize(int rows, int columns)
rows
- the number of rowscolumns
- the number of columns
Component.getPreferredSize()
public Dimension preferredSize(int rows, int columns)
getPreferredSize(int, int)
.
public Dimension getPreferredSize()
getPreferredSize
in class Component
Component.getPreferredSize()
public Dimension preferredSize()
getPreferredSize()
.
preferredSize
in class Component
public Dimension getMinimumSize(int rows, int columns)
rows
- the number of rowscolumns
- the number of columns
Component.getMinimumSize()
public Dimension minimumSize(int rows, int columns)
getMinimumSize(int, int)
.
public Dimension getMinimumSize()
getMinimumSize
in class Component
Component.getPreferredSize()
public Dimension minimumSize()
getMinimumSize()
.
minimumSize
in class Component
protected String paramString()
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
.
paramString
in class TextComponent
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException
HeadlessException
- if
GraphicsEnvironment.isHeadless()
returns
true
ClassNotFoundException
IOException
GraphicsEnvironment.isHeadless()
public javax.accessibility.AccessibleContext getAccessibleContext()
AccessibleContext
associated with
this TextArea
. For text areas, the
AccessibleContext
takes the form of an
AccessibleAWTTextArea
.
A new AccessibleAWTTextArea
instance is created if necessary.
getAccessibleContext
in interface javax.accessibility.Accessible
getAccessibleContext
in class TextComponent
AccessibleAWTTextArea
that serves as the
AccessibleContext
of this TextArea
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |