| Constructor: |
public TextArea() throws HeadlessException {
/* ensure that the necessary native libraries are loaded */
Toolkit.loadLibraries();
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
forwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet(
"ctrl TAB",
new HashSet());
backwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet(
"ctrl shift TAB",
new HashSet());
this("", 0, 0, SCROLLBARS_BOTH);
}
Constructs a new text area with the empty string as text.
This text area is created with scrollbar visibility equal to
#SCROLLBARS_BOTH , so both vertical and horizontal
scrollbars will be visible for this text area. Throws:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless()
- exception:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
|
public TextArea(String text) throws HeadlessException {
this(text, 0, 0, SCROLLBARS_BOTH);
}
Constructs a new text area with the specified text.
This 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; if
text is null, the empty
string "" will be displayed
Throws:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless()
- exception:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
|
public TextArea(int rows,
int columns) throws HeadlessException {
this("", rows, columns, SCROLLBARS_BOTH);
}
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 - if
GraphicsEnvironment.isHeadless returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless()
- exception:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
|
public TextArea(String text,
int rows,
int columns) throws HeadlessException {
this(text, rows, columns, SCROLLBARS_BOTH);
}
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; if
text is null, the empty
string "" will be displayed
rows - the number of rows
columns - the number of columns
Throws:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless()
- exception:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
|
public TextArea(String text,
int rows,
int columns,
int scrollbars) throws HeadlessException {
super(text);
this.rows = (rows >= 0) ? rows : 0;
this.columns = (columns >= 0) ? columns : 0;
if (scrollbars >= SCROLLBARS_BOTH && scrollbars < = SCROLLBARS_NONE) {
this.scrollbarVisibility = scrollbars;
} else {
this.scrollbarVisibility = SCROLLBARS_BOTH;
}
setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
forwardTraversalKeys);
setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
backwardTraversalKeys);
}
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 . 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 - if
GraphicsEnvironment.isHeadless returns true
Also see:
- java.awt.GraphicsEnvironment#isHeadless()
- since:
JDK1.1 -
- exception:
HeadlessException - if
GraphicsEnvironment.isHeadless returns true
|
| Methods from java.awt.Component: |
|---|
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventTypeEnabled, findNextFocusComponent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, generateName, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getGraphicsConfigurationImpl, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setPeer, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, translateEvent, update, validate |
| Method from java.awt.TextArea Detail: |
public void addNotify() {
synchronized (getTreeLock()) {
if (peer == null)
peer = getToolkit().createTextArea(this);
super.addNotify();
}
}
Creates the TextArea's peer. The peer allows us to modify
the appearance of the TextArea without changing any of its
functionality. |
public void append(String str) {
appendText(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. |
public synchronized void appendText(String str) {
if (peer != null) {
insertText(str, getText().length());
} else {
text = text + str;
}
} Deprecated! As - of JDK version 1.1,
replaced by append(String).
|
String constructComponentName() {
synchronized (TextArea.class) {
return base + nameCounter++;
}
}
Construct a name for this component. Called by getName
when the name is null. |
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTTextArea();
}
return accessibleContext;
}
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. |
public int getColumns() {
return columns;
}
Returns the number of columns in this text area. |
public Dimension getMinimumSize() {
return minimumSize();
}
Determines the minimum size of this text area. |
public Dimension getMinimumSize(int rows,
int columns) {
return minimumSize(rows, columns);
}
Determines the minimum size of a text area with the specified
number of rows and columns. |
public Dimension getPreferredSize() {
return preferredSize();
}
Determines the preferred size of this text area. |
public Dimension getPreferredSize(int rows,
int columns) {
return preferredSize(rows, columns);
}
Determines the preferred size of a text area with the specified
number of rows and columns. |
public int getRows() {
return rows;
}
Returns the number of rows in the text area. |
public int getScrollbarVisibility() {
return scrollbarVisibility;
}
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. |
public void insert(String str,
int pos) {
insertText(str, 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. |
public synchronized void insertText(String str,
int pos) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
if (peer != null) {
peer.insertText(str, pos);
} else {
text = text.substring(0, pos) + str + text.substring(pos);
}
} Deprecated! As - of JDK version 1.1,
replaced by insert(String, int).
|
public Dimension minimumSize() {
synchronized (getTreeLock()) {
return ((rows > 0) && (columns > 0)) ?
minimumSize(rows, columns) :
super.minimumSize();
}
} Deprecated! As - of JDK version 1.1,
replaced by getMinimumSize().
|
public Dimension minimumSize(int rows,
int columns) {
synchronized (getTreeLock()) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
return (peer != null) ?
peer.minimumSize(rows, columns) :
super.minimumSize();
}
} Deprecated! As - of JDK version 1.1,
replaced by getMinimumSize(int, int).
|
protected String paramString() {
String sbVisStr;
switch (scrollbarVisibility) {
case SCROLLBARS_BOTH:
sbVisStr = "both";
break;
case SCROLLBARS_VERTICAL_ONLY:
sbVisStr = "vertical-only";
break;
case SCROLLBARS_HORIZONTAL_ONLY:
sbVisStr = "horizontal-only";
break;
case SCROLLBARS_NONE:
sbVisStr = "none";
break;
default:
sbVisStr = "invalid display policy";
}
return super.paramString() + ",rows=" + rows +
",columns=" + columns +
",scrollbarVisibility=" + sbVisStr;
}
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. |
public Dimension preferredSize() {
synchronized (getTreeLock()) {
return ((rows > 0) && (columns > 0)) ?
preferredSize(rows, columns) :
super.preferredSize();
}
} Deprecated! As - of JDK version 1.1,
replaced by getPreferredSize().
|
public Dimension preferredSize(int rows,
int columns) {
synchronized (getTreeLock()) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
return (peer != null) ?
peer.preferredSize(rows, columns) :
super.preferredSize();
}
} Deprecated! As - of JDK version 1.1,
replaced by getPreferredSize(int, int).
|
public void replaceRange(String str,
int start,
int end) {
replaceText(str, start, 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. |
public synchronized void replaceText(String str,
int start,
int end) {
TextAreaPeer peer = (TextAreaPeer)this.peer;
if (peer != null) {
peer.replaceText(str, start, end);
} else {
text = text.substring(0, start) + str + text.substring(end);
}
} Deprecated! As - of JDK version 1.1,
replaced by replaceRange(String, int, int).
|
public void setColumns(int columns) {
int oldVal = this.columns;
if (columns < 0) {
throw new IllegalArgumentException("columns less than zero.");
}
if (columns != oldVal) {
this.columns = columns;
invalidate();
}
}
Sets the number of columns for this text area. |
public void setRows(int rows) {
int oldVal = this.rows;
if (rows < 0) {
throw new IllegalArgumentException("rows less than zero.");
}
if (rows != oldVal) {
this.rows = rows;
invalidate();
}
}
Sets the number of rows for this text area. |