java.awt
Class TextArea

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.TextComponent
              |
              +--java.awt.TextArea
All Implemented Interfaces:
java.awt.image.ImageObserver

public class TextArea
extends TextComponent

A TextArea object is a multi-line area that displays text. It can be set to allow editing or read-only modes.


Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TextArea()
          Constructs a new TextArea.
TextArea(int rows, int cols)
          Constructs a new TextArea with the specified number of rows and columns.
TextArea(String text)
          Constructs a new TextArea with the specified text displayed.
TextArea(String text, int rows, int cols)
          Constructs a new TextArea with the specified text and number of rows and columns.
 
Method Summary
 void addNotify()
          Creates the TextArea's peer.
 void appendText(String str)
          Appends the given text to the end.
 int getColumns()
          Returns the number of columns in the TextArea.
 int getRows()
          Returns the number of rows in the TextArea.
 void insertText(String str, int pos)
          Inserts the specified text at the specified position.
 Dimension minimumSize()
          Returns the minimum size Dimensions of the TextArea.
 Dimension minimumSize(int rows, int cols)
          Returns the specified minimum size Dimensions of the TextArea.
protected  String paramString()
          Returns the String of parameters for this TextArea.
 Dimension preferredSize()
          Returns the preferred size Dimensions of the TextArea.
 Dimension preferredSize(int rows, int cols)
          Returns the specified row and column Dimensions of the TextArea.
 void replaceText(String str, int start, int end)
          Replaces text from the indicated start to end position with the new text specified.
 
Methods inherited from class java.awt.TextComponent
getSelectedText, getSelectionEnd, getSelectionStart, getText, isEditable, removeNotify, select, selectAll, setEditable, setText
 
Methods inherited from class java.awt.Component
action, bounds, checkImage, checkImage, createImage, createImage, deliverEvent, disable, enable, enable, getBackground, getColorModel, getFont, getFontMetrics, getForeground, getGraphics, getParent, getPeer, getToolkit, gotFocus, handleEvent, hide, imageUpdate, inside, invalidate, isEnabled, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setFont, setForeground, show, show, size, toString, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextArea

public TextArea()
Constructs a new TextArea.


TextArea

public TextArea(int rows,
                int cols)
Constructs a new TextArea with the specified number of rows and columns.

Parameters:
rows - the number of rows
cols - the number of columns

TextArea

public TextArea(String text)
Constructs a new TextArea with the specified text displayed.

Parameters:
text - the text to be displayed

TextArea

public TextArea(String text,
                int rows,
                int cols)
Constructs a new TextArea with the specified text and number of rows and columns.

Parameters:
text - the text to be displayed
rows - the number of rows
cols - the number of cols
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
See Also:
Component.getPeer(), Component.removeNotify()

insertText

public void insertText(String str,
                       int pos)
Inserts the specified text at the specified position.

Parameters:
str - the text to insert.
pos - the position at which to insert.
See Also:
TextComponent.setText(java.lang.String), replaceText(java.lang.String, int, int)

appendText

public void appendText(String str)
Appends the given text to the end.

Parameters:
str - the text to insert
See Also:
insertText(java.lang.String, int)

replaceText

public void replaceText(String str,
                        int start,
                        int end)
Replaces text from the indicated start to end position with the new text specified.

Parameters:
str - the text to use as the replacement.
start - the start position.
end - the end position.
See Also:
insertText(java.lang.String, int), replaceText(java.lang.String, int, int)

getRows

public int getRows()
Returns the number of rows in the TextArea.


getColumns

public int getColumns()
Returns the number of columns in the TextArea.


preferredSize

public Dimension preferredSize(int rows,
                               int cols)
Returns the specified row and column Dimensions of the TextArea.

Parameters:
rows - the preferred rows amount
cols - the preferred columns amount

preferredSize

public Dimension preferredSize()
Returns the preferred size Dimensions of the TextArea.

Overrides:
preferredSize in class Component
See Also:
Component.minimumSize(), LayoutManager

minimumSize

public Dimension minimumSize(int rows,
                             int cols)
Returns the specified minimum size Dimensions of the TextArea.

Parameters:
rows - the minimum row size
cols - the minimum column size

minimumSize

public Dimension minimumSize()
Returns the minimum size Dimensions of the TextArea.

Overrides:
minimumSize in class Component
See Also:
Component.preferredSize(), LayoutManager

paramString

protected String paramString()
Returns the String of parameters for this TextArea.

Overrides:
paramString in class TextComponent