JTextComponent
Home ] Up ] [ JTextComponent ] JTextField ] JPasswordField ] JTextArea ] The Document Model ] JTextArea Scrolling ] JTextArea Editing ]

 

 

The abstract class JTextComponent is the superclass for all text components.  

It contains a number of useful methods, the most commonly used of which are:

Method Description
public void setText(String t)
Sets the text that is presented by this text component to be the specified text.
If t is null, the text is set to the empty string ("").
public String getText()
Gets the text that is presented by this text component.
public void setEditable(boolean b)
Sets the flag that determines whether or not this text component is editable.
If the flag is set to true, this text component becomes user editable. If the flag is set to false, the user cannot change the text of this text component.
public boolean isEditable()
Indicates whether or not this text component is editable.

These methods are pretty much self-describing.

There are also some other useful methods, but we won't cover them at this point.

 

This page was last modified on 02 October, 2007