Spec-Zone .ru
спецификации, руководства, описания, API
|
This section lists commonly used parts of the API that are shared by text components. Much of this API is defined by the
JTextComponent
class. Text Component Features discusses how to use some of this API.
The JComponent Class describes the API that text components inherit from JComponent
. For information about the API related to specific text components, see the how-to page for that component: text field, password field, formatted text field, text area, or editor pane and text pane.
For complete details about the text API, see the API documentation for
JTextComponent
The API listed in this section includes the following categories:
Method | Description |
---|---|
|
Sets or indicates whether the user can edit the text in the text component. |
|
Sets or gets the dragEnabled property, which must be true to enable drag handling on this component. The default value is false. See
|
void setDisabledTextColor(Color) |
Sets or gets the color used to display text when the text component is disabled. |
|
Sets or gets the margin between the text and the text component's border. |
Method | Description |
---|---|
|
Gets the currently selected text. |
|
Selects all text or selects text within a start and end range. |
|
Sets or gets the extent of the current selection by index. |
|
Sets or gets the color of selected text. |
|
Sets or gets the background color of selected text. |
Method | Description |
---|---|
|
Converts the specified point in the view coordinate system to a position within the text. |
|
Converts the specified position within the text to a rectangle in the view coordinate system. |
Class or Method | Description |
---|---|
(in JTextComponent ) |
Cuts, copies, and pastes text using the system clipboard, or replaces the selected text with the string specified by an argument, respectively. |
|
Provides a text component's view factory, document, caret, and actions, as well as reading and writing documents of a particular format. |
|
A concrete subclass of EditorKit that provides the basic text editing capabilities. |
|
A subclass of Default EditorKit that provides additional editing capabilities for styled text. |
(in DefaultEditorKit ) |
The names of all the actions supported by the default editor kit. See Associating Text Actions with Menus and Buttons. |
(in DefaultEditorKit ) |
Inner classes that implement various text editing commands. |
(in StyledEditorKit ) |
Inner classes that implement various editing commands for styled text. |
(in JTextComponent ) |
Gets the actions supported by this component. This method gets the array of actions from the editor kit if one is used by the component. |
(in JComponent ) |
Gets the input map that binds key strokes to actions. See Associating Text Actions with Key Strokes. |
(in InputMap ) |
Binds the specified key to the specified action. You generally specify the action by its name, which for standard editing actions is represented by a string constant such as DefaultEditorKit.backwardAction . |
Interface or Class | Description |
---|---|
|
An interface that defines the API that must be implemented by all documents. |
|
An abstract superclass implementation of the Document interface. This is the superclass for all documents provided by the Swing text package. |
|
A class that implements the Document interface. This is the default document for the plain text components (text field, password field, and text area). Additionally, this class is used by the editor panes and text panes when loading plain text or text of an unknown format. |
|
A Document subinterface. Defines the API that must be implemented by documents that support styled text. JTextPane requires that its document be of this type. |
|
A class that implements the StyledDocument interface. The default document for JTextPane . |
Class or Method | Description |
---|---|
|
The superclass of all document filters. You can use a document filter to change what gets inserted or removed from a document, without having to implement a document yourself. See Implementing a Document Filter. |
(in AbstractDocument ) |
Sets the document filter. |
(in JTextComponent ) |
Sets or gets the document for a text component. |
(in JTextField ) |
Creates a default PlainDocument model. Override this method to create a custom document instead of the default PlainDocument . |
(in Document ) |
Adds or removes a document listener. See Listening for Changes on a Document. |
(in Document ) |
Adds or removes an undoable edit listener. Undoable edit listeners are used in Implementing Undo and Redo. |
(in Document ) |
Document methods that return various descriptive information about the document. |
(in Document )(in AbstractDocument ) |
A Document maintains a set of properties that you can manipulate with these methods. |
Interface, Class, or Method | Description |
---|---|
|
An interface that defines the API for objects that represent an insertion point within documents. |
|
The default caret used by all text components. |
|
Sets or gets the caret object used by a text component. |
|
Sets or gets the color of the caret. |
|
Sets or gets the current position of the caret within the document. |
|
Adds or removes a caret listener from a text component. |
|
The superclass for all navigation filters. A navigation filter lets you modify caret changes that are about to occur for a text component. |
|
Attaches a navigation filter to a text component. |
|
An interface that defines the API for objects used to highlight the current selection. |
|
The default highlighter used by all text components. |
|
Sets or gets the highlighter used by a text component. |
Method | Description |
---|---|
(in JTextComponent ) |
Reads or writes text. |
(in EditorKit ) |
Reads text from a stream into a document. |
(in EditorKit ) |
Writes text from a document to a stream. |