All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.swing.JTextArea
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.swing.JComponent
|
+----java.awt.swing.text.JTextComponent
|
+----java.awt.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.
JTextArea()
- Constructs a new TextArea.
JTextArea(Document)
- Constructs a new JTextArea with the given document model, and defaults
for all of the other arguments.
JTextArea(Document, String, int, int)
- Constructs a new JTextArea with the specified number of rows
and columns, and the given model.
JTextArea(int, int)
- Constructs a new empty TextArea with the specified number of
rows and columns.
JTextArea(String)
- Constructs a new TextArea with the specified text displayed.
JTextArea(String, int, int)
- Constructs a new TextArea with the specified text and number
of rows and columns.
append(String)
- Appends the given text to the end of the document.
createDefaultModel()
- Creates the default implementation of the model
to be used at construction if one isn't explicitly
given.
getColumns()
- Returns the number of columns in the TextArea.
getColumnWidth()
- Gets column width.
getMinimumSize()
- Returns the minimum size Dimensions of the TextArea.
getPreferredSize()
- Returns the preferred size Dimensions of the TextArea.
getRowHeight()
- Defines the meaning of the height of a row.
getRows()
- Returns the number of rows in the TextArea.
getTabSize()
- Gets the number of characters used to expand tabs.
getUIClassID()
- Returns the class ID for the UI.
insert(String, int)
- Inserts the specified text at the specified position.
isManagingFocus()
- Turn off tab traversal once focus gained.
paramString()
- Returns the String of parameters for this TextArea.
replaceRange(String, int, int)
- Replaces text from the indicated start to end position with the
new text specified.
setColumns(int)
- Sets the number of columns for this TextArea.
setFont(Font)
- Sets the current font.
setRows(int)
- Sets the number of rows for this TextArea.
setTabSize(int)
- Sets the number of characters to expand tabs to.
JTextArea
public JTextArea()
- Constructs a new TextArea.
JTextArea
public JTextArea(String text)
- Constructs a new TextArea with the specified text displayed.
- Parameters:
- text - the text to be displayed
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
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
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
JTextArea
public JTextArea(Document doc,
String text,
int rows,
int columns)
- 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
getUIClassID
public String getUIClassID()
- Returns the class ID for the UI.
- Returns:
- the ID
- Overrides:
- getUIClassID in class JComponent
- See Also:
- getUIClassID, getUI
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
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
getTabSize
public int getTabSize()
- Gets the number of characters used to expand tabs.
- Returns:
- the number of characters
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
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
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
isManagingFocus
public boolean isManagingFocus()
- Turn off tab traversal once focus gained.
- Overrides:
- isManagingFocus in class JComponent
getRows
public int getRows()
- Returns the number of rows in the TextArea.
- Returns:
- the number of rows
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
getRowHeight
protected int getRowHeight()
- Defines the meaning of the height of a row. This defaults to
the height of the font.
- Returns:
- the height
getColumns
public int getColumns()
- Returns the number of columns in the TextArea.
- Returns:
- number of columns
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
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
getPreferredSize
public Dimension getPreferredSize()
- Returns the preferred size Dimensions of the TextArea.
- Returns:
- the dimensions
- Overrides:
- getPreferredSize in class JComponent
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
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
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
Submit a bug or feature