ImageObserver
, MenuContainer
, Serializable
, Accessible
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 Classes
protected class
This class implements accessibility support for the TextArea
class.
Fields
static final int
Create and display both vertical and horizontal scrollbars.
static final int
Create and display horizontal scrollbar only.
static final int
Do not create or display any scrollbars for the text area.
static final int
Create and display vertical scrollbar only.
Constructors
Constructs a new text area with the empty string as text.
Constructs a new text area with the specified number of rows and columns and the empty string as text.
Constructs a new text area with the specified text.
Constructs a new text area with the specified text, and with the specified number of rows and columns.
Constructs a new text area with the specified text, and with the rows, columns, and scroll bar visibility as specified.
void
Creates the TextArea
's peer.
void
Appends the given text to the text area's current text.
void
Returns the AccessibleContext
associated with this TextArea
.
int
Returns the number of columns in this text area.
Determines the minimum size of this text area.
Determines the minimum size of a text area with the specified number of rows and columns.
Determines the preferred size of this text area.
Determines the preferred size of a text area with the specified number of rows and columns.
int
Returns the number of rows in the text area.
int
Returns an enumerated value that indicates which scroll bars the text area uses.
void
Inserts the specified text at the specified position in this text area.
void
Returns a string representing the state of this TextArea
.
void
Replaces text between the indicated start and end positions with the specified replacement text.
void
void
Sets the number of columns for this text area.
void
Sets the number of rows for this text area.
Methods declared in class java.awt.TextComponentaddTextListener, enableInputMethods, getBackground, getCaretPosition, getListeners, getSelectedText, getSelectionEnd, getSelectionStart, getText, getTextListeners, isEditable, processEvent, processTextEvent, removeNotify, removeTextListener, select, selectAll, setBackground, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
Methods declared in class java.awt.Componentaction, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBaseline, getBaselineResizeBehavior, 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, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
public static final int SCROLLBARS_BOTH
Create and display both vertical and horizontal scrollbars.
public static final int SCROLLBARS_VERTICAL_ONLY
Create and display vertical scrollbar only.
public static final int SCROLLBARS_HORIZONTAL_ONLY
Create and display horizontal scrollbar only.
public static final int SCROLLBARS_NONE
Do not create or display any scrollbars for the text area.
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.
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
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.
text
- the text to be displayed; if text
is null
, the empty string ""
will be displayed
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
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.
rows
- the number of rows
columns
- the number of columns
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
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.
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
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
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
.
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
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
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.
addNotify
in class TextComponent
Note that passing null
or inconsistent parameters is invalid and will result in unspecified behavior.
str
- the non-null
text to insert
pos
- the position at which to insert
Inserts the specified text at the specified position in this text area.
str
- the non-null
text to insert
pos
- the position at which to insert
Note that passing null
or inconsistent parameters is invalid and will result in unspecified behavior.
str
- the non-null
text to append
Appends the given text to the text area's current text.
str
- the text to append
Note that passing null
or inconsistent parameters is invalid and will result in unspecified behavior.
str
- the non-null
text to use as the replacement
start
- the start position
end
- the end position
Replaces a range of characters between the indicated start and end positions with the specified replacement text (the text at the end position will not be replaced).
str
- the non-null
text to use as the replacement
start
- the start position
end
- the end position
public int getRows()
Returns the number of rows in the text area.
public void setRows(int rows)
Sets the number of rows for this text area.
rows
- the number of rows
IllegalArgumentException
- if the value supplied for rows
is less than 0
public int getColumns()
Returns the number of columns in this text area.
public void setColumns(int columns)
Sets the number of columns for this text area.
columns
- the number of columns
IllegalArgumentException
- if the value supplied for columns
is less than 0
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.
Determines the preferred size of a text area with the specified number of rows and columns.
rows
- the number of rows
columns
- the number of columns
Determines the preferred size of the text area with the specified number of rows and columns.
rows
- the number of rows
columns
- the number of columns
Determines the preferred size of this text area.
getPreferredSize
in class Component
Returns the component's preferred size.
preferredSize
in class Component
Determines the minimum size of a text area with the specified number of rows and columns.
rows
- the number of rows
columns
- the number of columns
Determines the minimum size of the text area with the specified number of rows and columns.
rows
- the number of rows
columns
- the number of columns
Determines the minimum size of this text area.
getMinimumSize
in class Component
Returns the minimum size of this component.
minimumSize
in class Component
()
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
.
paramString
in class TextComponent
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.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class TextComponent
AccessibleAWTTextArea
that serves as the AccessibleContext
of this TextArea
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4