Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.TextArea

java.lang.Object
    |
    +----java.awt.Component
            |
            +----java.awt.TextComponent
                    |
                    +----java.awt.TextArea

public class TextArea
extends TextComponent
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);
 

Since:
JDK1.0

Field Summary
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.
 
Fields inherited from class java.awt.TextComponent
 textListener
 
Fields inherited from class java.awt.Component
 BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 

Constructor Summary
 TextArea()
Constructs a new text area.
 TextArea(String text)
Constructs a new text area with the specified text.
 TextArea(int rows, int columns)
Constructs a new empty TextArea with the specified number of rows and columns.
 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
int  getColumns()
Gets the number of columns in 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  getMinimumSize()
Determines the minimum 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.
Dimension  getPreferredSize()
Determines the preferred size of this text area.
int  getRows()
Gets the number of rows in the text area.
int  getScrollbarVisibility()
Gets an enumerated value that indicates which scroll bars the text area uses.
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
Dimension  minimumSize(int rows, int columns)
  Deprecated
Dimension  minimumSize()
  Deprecated
String  paramString()
Returns the parameter string representing the state of this text area.
Dimension  preferredSize(int rows, int columns)
  Deprecated
Dimension  preferredSize()
  Deprecated
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
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.awt.TextComponent
 addTextListener, getCaretPosition, getSelectedText, getSelectionEnd, getSelectionStart, getText, isEditable, paramString, processEvent, processTextEvent, removeNotify, removeTextListener, select, selectAll, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
 
Methods inherited from class java.awt.Component
 action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getColorModel, getComponentAt, getComponentAt, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isEnabled, isFocusTraversable, 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, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCROLLBARS_BOTH

public static final int SCROLLBARS_BOTH
Create and display both vertical and horizontal scrollbars.

SCROLLBARS_VERTICAL_ONLY

public static final int SCROLLBARS_VERTICAL_ONLY
Create and display vertical scrollbar only.

SCROLLBARS_HORIZONTAL_ONLY

public static final int SCROLLBARS_HORIZONTAL_ONLY
Create and display horizontal scrollbar only.

SCROLLBARS_NONE

public static final int SCROLLBARS_NONE
Do not create or display any scrollbars for the text area.
Constructor Detail

TextArea

public TextArea()
Constructs a new text area. This text area is created with both vertical and horizontal scroll bars.

TextArea

public TextArea(String text)
Constructs a new text area with the specified text. This text area is created with both vertical and horizontal scroll bars.
Parameters:
text - the text to be displayed.

TextArea

public TextArea(int rows,
                int columns)
Constructs a new empty TextArea with the specified number of rows and columns.
Parameters:
rows - the number of rows
columns - the number of columns

TextArea

public 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. This text area is created with both vertical and horizontal scroll bars.
Parameters:
text - the text to be displayed.
rows - the number of rows.
columns - the number of columns.

TextArea

public 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.

The TextArea class defines several constants that can be supplied as values for the scrollbars argument: SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, and SCROLLBARS_NONE.

Parameters:
text - the text to be displayed.
rows - the number of rows.
columns - the number of columns.
scrollbars - a constant that determines what scrollbars are created to view the text area.
Method Detail

addNotify

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.
Overrides:
addNotify in class Component

insert

public void insert(String str,
                   int pos)
Inserts the specified text at the specified position in this text area.
Parameters:
str - the text to insert.
pos - the position at which to insert.
See Also:
setText, replaceRange, append

insertText

public void insertText(String str,
                       int pos)
Note: insertText() is deprecated.As of JDK version 1.1, replaced by insert(String, int).


append

public void append(String str)
Appends the given text to the text area's current text.
Parameters:
str - the text to append.
See Also:
insert

appendText

public void appendText(String str)
Note: appendText() is deprecated.As of JDK version 1.1, replaced by append(String).


replaceRange

public void replaceRange(String str,
                         int start,
                         int end)
Replaces text between the indicated start and end positions with the specified replacement text.
Parameters:
str - the text to use as the replacement.
start - the start position.
end - the end position.
See Also:
insert

replaceText

public void replaceText(String str,
                        int start,
                        int end)
Note: replaceText() is deprecated.As of JDK version 1.1, replaced by replaceRange(String, int, int).


getRows

public int getRows()
Gets the number of rows in the text area.
Returns:
the number of rows in the text area.
See Also:
setRows, getColumns

setRows

public void setRows(int rows)
Sets the number of rows for this text area.
Parameters:
rows - the number of rows.
Throws:
IllegalArgumentException - if the value supplied for rows is less than zero.
See Also:
getRows, setColumns

getColumns

public int getColumns()
Gets the number of columns in this text area.
Returns:
the number of columns in the text area.
See Also:
setColumns, getRows

setColumns

public void setColumns(int columns)
Sets the number of columns for this text area.
Parameters:
columns - the number of columns.
Throws:
IllegalArgumentException - if the value supplied for columns is less than zero.
See Also:
getColumns, setRows

getScrollbarVisibility

public int getScrollbarVisibility()
Gets 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.

Returns:
an integer that indicates which scroll bars are used.
See Also:
SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, TextArea(java.lang.String, int, int, int)

getPreferredSize

public Dimension getPreferredSize(int rows,
                                  int columns)
Determines the preferred size of a text area with the specified number of rows and columns.
Parameters:
rows - the number of rows.
cols - the number of columns.
Returns:
the preferred dimensions required to display the text area with the specified number of rows and columns.
See Also:
getPreferredSize

preferredSize

public Dimension preferredSize(int rows,
                               int columns)
Note: preferredSize() is deprecated.As of JDK version 1.1, replaced by getPreferredSize(int, int).


getPreferredSize

public Dimension getPreferredSize()
Determines the preferred size of this text area.
Returns:
the preferred dimensions needed for this text area.
Overrides:
getPreferredSize in class Component
See Also:
getPreferredSize

preferredSize

public Dimension preferredSize()
Note: preferredSize() is deprecated.As of JDK version 1.1, replaced by getPreferredSize().

Overrides:
preferredSize in class Component

getMinimumSize

public Dimension getMinimumSize(int rows,
                                int columns)
Determines the minimum size of a text area with the specified number of rows and columns.
Parameters:
rows - the number of rows.
cols - the number of columns.
Returns:
the minimum dimensions required to display the text area with the specified number of rows and columns.
See Also:
getMinimumSize

minimumSize

public Dimension minimumSize(int rows,
                             int columns)
Note: minimumSize() is deprecated.As of JDK version 1.1, replaced by getMinimumSize(int, int).


getMinimumSize

public Dimension getMinimumSize()
Determines the minimum size of this text area.
Returns:
the preferred dimensions needed for this text area.
Overrides:
getMinimumSize in class Component
See Also:
getPreferredSize

minimumSize

public Dimension minimumSize()
Note: minimumSize() is deprecated.As of JDK version 1.1, replaced by getMinimumSize().

Overrides:
minimumSize in class Component

paramString

protected String paramString()
Returns the parameter string representing the state of this text area. This string is useful for debugging.
Returns:
the parameter string of this text area.
Overrides:
paramString in class TextComponent

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.