All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JTextArea

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.text.JTextComponent
                                   |
                                   +----com.sun.java.swing.JTextArea

public class JTextArea
extends JTextComponent
A TextArea is a multi-line area that displays plain text. It can be set to allow editing or read-only modes. It is intended to be a lightweight component that provides source compatibility with the java.awt.TextArea class where it can reasonably do so.


Variable Index

 o SCROLLBARS_BOTH
Create and display both vertical and horizontal scrollbars.
 o SCROLLBARS_HORIZONTAL_ONLY
Create and display horizontal scrollbar only.
 o SCROLLBARS_NONE
Do not create or display any scrollbars for the text area.
 o SCROLLBARS_VERTICAL_ONLY
Create and display vertical scrollbar only.

Constructor Index

 o JTextArea()
Constructs a new TextArea.
 o JTextArea(Document)
Constructs a new JTextArea with the given document model, and defaults for all of the other arguments.
 o JTextArea(Document, String, int, int, int)
Constructs a new JTextArea with the specified number of rows and columns, and the given model.
 o JTextArea(int, int)
Constructs a new empty TextArea with the specified number of rows and columns.
 o JTextArea(String)
Constructs a new TextArea with the specified text displayed.
 o JTextArea(String, int, int)
Constructs a new TextArea with the specified text and number of rows and columns.
 o JTextArea(String, int, int, int)
Constructs a new TextArea with the specified text and number of rows, columns, and scrollbar visibility.

Method Index

 o append(String)
Appends the given text to the end of the document.
 o createDefaultModel()
Creates the default implementation of the model to be used at construction if one isn't explicitly given.
 o getColumns()
Returns the number of columns in the TextArea.
 o getColumnWidth()
Gets column width.
 o getMinimumSize()
Returns the minimum size Dimensions of the TextArea.
 o getPreferredSize()
Returns the preferred size Dimensions of the TextArea.
 o getRowHeight()
Defines the meaning of the height of a row.
 o getRows()
Returns the number of rows in the TextArea.
 o getScrollbarVisibility()
Returns the enumerated value describing which scrollbars the text area has.
 o getTabSize()
Gets the number of characters used to expand tabs.
 o getUIClassID()
 o insert(String, int)
Inserts the specified text at the specified position.
 o isManagingFocus()
Turn off tab traversal once focus gained.
 o paramString()
Returns the String of parameters for this TextArea.
 o replaceRange(String, int, int)
Replaces text from the indicated start to end position with the new text specified.
 o setColumns(int)
Sets the number of columns for this TextArea.
 o setFont(Font)
Sets the current font.
 o setRows(int)
Sets the number of rows for this TextArea.
 o setTabSize(int)
Sets the number of characters to expand tabs to.

Variables

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

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

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

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

Constructors

 o JTextArea
 public JTextArea()
Constructs a new TextArea.

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

Parameters:
text - the text to be displayed
 o JTextArea
 public JTextArea(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
 o JTextArea
 public JTextArea(String text,
                  int rows,
                  int columns)
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
columns - the number of columns
 o JTextArea
 public JTextArea(String text,
                  int rows,
                  int columns,
                  int scrollbars)
Constructs a new TextArea with the specified text and number of rows, columns, and scrollbar visibility.

Parameters:
text - the text to be displayed
rows - the number of rows
columns - the number of columns
scrollbars - the visibility of scrollbars
 o JTextArea
 public JTextArea(Document doc)
Constructs a new JTextArea with the given document model, and defaults for all of the other arguments.

Parameters:
doc - the model to use
 o JTextArea
 public JTextArea(Document doc,
                  String text,
                  int rows,
                  int columns,
                  int scrollbars)
Constructs a new JTextArea with the specified number of rows and columns, and the given model. All of the constructors feed through this constructor.

Parameters:
doc - the model to use
text - the text to be displayed
rows - the number of rows
columns - the number of columns
scrollbars - scrollbar visibility

Methods

 o getUIClassID
 public String getUIClassID()
Returns:
"TextAreaUI"
Overrides:
getUIClassID in class JComponent
See Also:
getUIClassID, getUI
 o createDefaultModel
 protected Document createDefaultModel()
Creates the default implementation of the model to be used at construction if one isn't explicitly given.

Returns:
the default document model
 o setTabSize
 public void setTabSize(int size)
Sets the number of characters to expand tabs to. This will be multiplied by the maximum advance for variable width fonts.

Parameters:
size - number of characters to expand to
 o getTabSize
 public int getTabSize()
Gets the number of characters used to expand tabs.

Returns:
the number of characters
 o insert
 public void insert(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
Throws: IllegalArgumentException
if pos is an invalid position in the model
See Also:
setText, replaceRange
 o append
 public void append(String str)
Appends the given text to the end of the document.

Parameters:
str - the text to insert
See Also:
insert
 o replaceRange
 public void replaceRange(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
Throws: IllegalArgumentException
if part of the range is an invalid position in the model
See Also:
insert, replaceRange
 o isManagingFocus
 public boolean isManagingFocus()
Turn off tab traversal once focus gained.

Overrides:
isManagingFocus in class JComponent
 o getRows
 public int getRows()
Returns the number of rows in the TextArea.

Returns:
the number of rows
 o setRows
 public void setRows(int rows)
Sets the number of rows for this TextArea.

Parameters:
rows - the number of rows
Throws: IllegalArgumentException
if rows is less than 0
 o getRowHeight
 protected int getRowHeight()
Defines the meaning of the height of a row. This defaults to the height of the font.

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

Returns:
number of columns
 o setColumns
 public void setColumns(int columns)
Sets the number of columns for this TextArea.

Parameters:
columns - the number of columns
Throws: IllegalArgumentException
if columns is less than 0
 o getColumnWidth
 protected int getColumnWidth()
Gets column width. The meaning of what a column is can be considered a fairly weak notion for some fonts. This method is used to define the width of a column. By default this is defined to be the width of the character m for the font used. This method can be redefined to be some alternative amount.

Returns:
the column width
 o getScrollbarVisibility
 public int getScrollbarVisibility()
Returns the enumerated value describing which scrollbars the text area has.

Returns:
the display policy for the scrollbars
 o getPreferredSize
 public Dimension getPreferredSize()
Returns the preferred size Dimensions of the TextArea.

Returns:
the dimensions
Overrides:
getPreferredSize in class JComponent
 o getMinimumSize
 public Dimension getMinimumSize()
Returns the minimum size Dimensions of the TextArea. By default this is set to the preferred size.

Returns:
the dimensions
Overrides:
getMinimumSize in class JComponent
 o setFont
 public void setFont(Font f)
Sets the current font. This removes cached row height and column width so the new font will be reflected.

Parameters:
f - the font to use as the current font
Overrides:
setFont in class Component
 o paramString
 protected String paramString()
Returns the String of parameters for this TextArea.

Returns:
the string of parameters
Overrides:
paramString in class Container

All Packages  Class Hierarchy  This Package  Previous  Next  Index