java.lang.Object java.awt.Component java.awt.TextComponent java.awt.TextArea
public class 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);
TextArea()
TextArea(int rows, int columns)
TextArea(String text)
TextArea(String text, int rows, int columns)
TextArea(String text, int rows, int columns, int scrollbars)
void
addNotify()
TextArea
's peer. void
append(String str)
void
appendText(String str)
append(String)
. AccessibleContext
getAccessibleContext()
AccessibleContext
associated with this TextArea
. int
getColumns()
Dimension
getMinimumSize()
Dimension
getMinimumSize(int rows, int columns)
Dimension
getPreferredSize()
Dimension
getPreferredSize(int rows, int columns)
int
getRows()
int
getScrollbarVisibility()
void
insert(String str, int pos)
void
insertText(String str, int pos)
insert(String, int)
. Dimension
minimumSize()
getMinimumSize()
. Dimension
minimumSize(int rows, int columns)
getMinimumSize(int, int)
. protected String
paramString()
TextArea
. Dimension
preferredSize()
getPreferredSize()
. Dimension
preferredSize(int rows, int columns)
getPreferredSize(int, int)
. void
replaceRange(String str, int start, int end)
void
replaceText(String str, int start, int end)
replaceRange(String, int, int)
. void
setColumns(int columns)
void
setRows(int rows)
addTextListener, enableInputMethods, getBackground, getCaretPosition, getInputMethodRequests, getListeners, getSelectedText, getSelectionEnd, getSelectionStart, getText, getTextListeners, isEditable, processEvent, processTextEvent, removeNotify, removeTextListener, select, selectAll, setBackground, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
Methods inherited from class java.awt.Component 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, 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, 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
SCROLLBARS_BOTH
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() throws HeadlessException
SCROLLBARS_BOTH
, so both vertical and horizontal scrollbars will be visible for this text area.
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
GraphicsEnvironment.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 true
GraphicsEnvironment.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 rows
columns
- the number of columns
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
GraphicsEnvironment.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 displayed
rows
- the number of rows
columns
- the number of columns
HeadlessException
- if GraphicsEnvironment.isHeadless
returns true
GraphicsEnvironment.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 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
GraphicsEnvironment.isHeadless()
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 insert
pos
- the position at which to insert
TextComponent.setText(java.lang.String)
, replaceRange(java.lang.String, int, int)
, append(java.lang.String)
@Deprecated 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 append
insert(java.lang.String, int)
@Deprecated 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 replacement
start
- the start position
end
- the end position
insert(java.lang.String, int)
@Deprecated 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 rows
columns
- the number of columns
Component.getPreferredSize()
@Deprecated public Dimension preferredSize(int rows, int columns)
getPreferredSize(int, int)
.
public Dimension getPreferredSize()
getPreferredSize
in class Component
Component.getPreferredSize()
@Deprecated public Dimension preferredSize()
getPreferredSize()
.
preferredSize
in class Component
public Dimension getMinimumSize(int rows, int columns)
rows
- the number of rows
columns
- the number of columns
Component.getMinimumSize()
@Deprecated public Dimension minimumSize(int rows, int columns)
getMinimumSize(int, int)
.
public Dimension getMinimumSize()
getMinimumSize
in class Component
Component.getPreferredSize()
@Deprecated 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
public 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 Accessible
getAccessibleContext
in class TextComponent
AccessibleAWTTextArea
that serves as the AccessibleContext
of this TextArea
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
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