java.awt
public class TextArea extends TextComponent implements Serializable
Modifier and Type | Class and Description |
---|---|
protected class |
TextArea.AccessibleAWTTextArea |
TextComponent.AccessibleAWTTextComponent
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
static int |
SCROLLBARS_BOTH
Display both horiztonal and vertical scroll bars.
|
static int |
SCROLLBARS_HORIZONTAL_ONLY
Display horizatonal scroll bar only.
|
static int |
SCROLLBARS_NONE
Do not display scrollbars.
|
static int |
SCROLLBARS_VERTICAL_ONLY
Display vertical scroll bar only.
|
textListener
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TextArea()
Initialize a new instance of
TextArea that is empty. |
TextArea(int rows,
int columns)
Initialize a new instance of
TextArea that is empty
and can display the specified number of rows and columns of text,
without the need to scroll. |
TextArea(String text)
Initialize a new instance of
TextArea that contains
the specified text. |
TextArea(String text,
int rows,
int columns)
Initialize a new instance of
TextArea that can
display the specified number of rows and columns of text, without
the need to scroll. |
TextArea(String text,
int rows,
int columns,
int scrollbarVisibility)
Initialize a new instance of
TextArea that initially
contains the specified text. |
Modifier and Type | Method and Description |
---|---|
void |
addNotify()
Notify this object that it should create its native peer.
|
void |
append(String str)
Append the specified text to the end of the current text.
|
void |
appendText(String str)
Deprecated.
This method is deprecated in favor of
append () . |
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this
TextArea . |
int |
getColumns()
Retrieve the number of columns that this text area would prefer
to display.
|
Dimension |
getMinimumSize()
Retrieve the minimum size for this text area.
|
Dimension |
getMinimumSize(int rows,
int columns)
Retrieve the minimum size for this text area.
|
Dimension |
getPreferredSize()
Retrieve the preferred size for this text area.
|
Dimension |
getPreferredSize(int rows,
int columns)
Retrieve the preferred size for this text area.
|
int |
getRows()
Retrieve the number of rows that this text area would prefer to
display.
|
int |
getScrollbarVisibility()
Retrieve the scroll bar display policy -- one of SCROLLBARS_BOTH,
SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY,
SCROLLBARS_NONE.
|
void |
insert(String str,
int pos)
Insert the specified text at the specified position.
|
void |
insertText(String str,
int pos)
Deprecated.
This method is deprecated in favor of
insert () . |
Dimension |
minimumSize()
Deprecated.
This method is deprecated in favor of
getMinimumSize () . |
Dimension |
minimumSize(int rows,
int columns)
Deprecated.
This method is deprecated in favor of
getMinimumSize (int, int) . |
protected String |
paramString()
Retrieve a debugging string for this text area.
|
Dimension |
preferredSize()
Deprecated.
This method is deprecated in favor of
getPreferredSize () . |
Dimension |
preferredSize(int rows,
int columns)
Deprecated.
This method is deprecated in favor of
getPreferredSize (int, int) . |
void |
replaceRange(String str,
int start,
int end)
Replace a range of characters with the specified text.
|
void |
replaceText(String str,
int start,
int end)
Deprecated.
This method is deprecated in favor of
replaceRange () . |
void |
setColumns(int columns)
Set the preferred number of columns for this text area.
|
void |
setRows(int rows)
Set the preferred number of rows for this text area.
|
addTextListener, getCaretPosition, getListeners, getSelectedText, getSelectionEnd, getSelectionStart, getText, getTextListeners, isEditable, processEvent, processTextEvent, removeNotify, removeTextListener, select, selectAll, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
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
public TextArea()
TextArea
that is empty.
Conceptually the TextArea
has 0 rows and 0 columns
but its initial bounds are defined by its peer or by the
container in which it is packed. Both horizontal and vertical
scrollbars will be displayed.HeadlessException
- if GraphicsEnvironment.isHeadless () is truepublic TextArea(String text)
TextArea
that contains
the specified text. Conceptually the TextArea
has 0
rows and 0 columns but its initial bounds are defined by its peer
or by the container in which it is packed. Both horizontal and
veritcal scrollbars will be displayed. The TextArea initially contains
the specified text. If text specified as null, it will
be set to "".
text
- The text to display in this text area (null
permitted).HeadlessException
- if GraphicsEnvironment.isHeadless () is truepublic TextArea(int rows, int columns)
TextArea
that is empty
and can display the specified number of rows and columns of text,
without the need to scroll. Both horizontal and vertical
scrollbars will be displayed.rows
- The number of rows in this text area.columns
- The number of columns in this text area.HeadlessException
- if GraphicsEnvironment.isHeadless () is truepublic TextArea(String text, int rows, int columns)
TextArea
that can
display the specified number of rows and columns of text, without
the need to scroll. The TextArea initially contains the
specified text. If text specified as null, it will
be set to "".
text
- The text to display in this text area (null
permitted).rows
- The number of rows in this text area.columns
- The number of columns in this text area.HeadlessException
- if GraphicsEnvironment.isHeadless () is truepublic TextArea(String text, int rows, int columns, int scrollbarVisibility)
TextArea
that initially
contains the specified text. The TextArea can display the
specified number of rows and columns of text, without the need to
scroll. This constructor allows specification of the scroll bar
display policy. The TextArea initially contains the specified text.
If text specified as null, it will be set to "".
text
- The text to display in this text area (null
permitted).rows
- The number of rows in this text area.columns
- The number of columns in this text area.scrollbarVisibility
- The scroll bar display policy. One of
SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY,
SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE.HeadlessException
- if GraphicsEnvironment.isHeadless () is truepublic int getColumns()
public void setColumns(int columns)
columns
- The preferred number of columns.IllegalArgumentException
- If columns is less than zero.public int getRows()
public void setRows(int rows)
rows
- The preferred number of rows.IllegalArgumentException
- If rows is less than zero.public Dimension getMinimumSize()
getMinimumSize
in class Component
Component.getPreferredSize()
,
Component.setMinimumSize(Dimension)
,
LayoutManager
public Dimension getMinimumSize(int rows, int columns)
rows
- The number of rows to use in the minimum size
calculation.columns
- The number of columns to use in the minimum size
calculation.public Dimension minimumSize()
getMinimumSize ()
.minimumSize
in class Component
public Dimension minimumSize(int rows, int columns)
getMinimumSize (int, int)
.rows
- The number of rows to use in the minimum size
calculation.columns
- The number of columns to use in the minimum size
calculation.public Dimension getPreferredSize()
getPreferredSize
in class Component
Component.getMinimumSize()
,
Component.setPreferredSize(Dimension)
,
LayoutManager
public Dimension getPreferredSize(int rows, int columns)
rows
- The number of rows to use in the preferred size
calculation.columns
- The number of columns to use in the preferred size
calculation.public Dimension preferredSize()
getPreferredSize ()
.preferredSize
in class Component
public Dimension preferredSize(int rows, int columns)
getPreferredSize (int, int)
.rows
- The number of rows to use in the preferred size
calculation.columns
- The number of columns to use in the preferred size
calculation.public int getScrollbarVisibility()
public void addNotify()
addNotify
in class Component
Component.isDisplayable()
,
Component.removeNotify()
public void append(String str)
str
- The text to append.public void appendText(String str)
append ()
.str
- The text to append.public void insert(String str, int pos)
str
- The text to insert.pos
- The position at which to insert text.public void insertText(String str, int pos)
insert ()
.str
- The text to insert.pos
- The position at which to insert text.public void replaceRange(String str, int start, int end)
str
- The new text for the range.start
- The start position of the replacement range.end
- The end position of the replacement range.public void replaceText(String str, int start, int end)
replaceRange ()
.str
- The new text for the range.start
- The start position of the replacement range.end
- The end position of the replacement range.protected String paramString()
paramString
in class TextComponent
public AccessibleContext getAccessibleContext()
TextArea
.
The context is created, if necessary.getAccessibleContext
in interface Accessible
getAccessibleContext
in class TextComponent