Java Reference
In-Depth Information
Table 15-1. JTextComponent Properties (Continued)
Property Name
Data Type
Access
selectedText
String
Read-only
selectedTextColor
Color
Read-write bound
selectionColor
Color
Read-write bound
selectionEnd
int
Read-write
selectionStart
int
Read-write
text
String
Read-write
UI
TextUI
Read-write
These properties can be grouped into eight basic categories:
Data model: The document property is for the data model of all text components. The
text property is used for treating this data model as a String .
Color: The caretColor , disabledTextColor , selectedTextColor , and selectionColor
properties, as well as the inherited foreground and background properties, specify the
color for rendering the cursor, disabled text, selected text, selected text background,
regular text, and regular text background.
Caret: The caret , caretPosition , and navigationFilter properties are for navigating
through the document.
Highlighter: The highlighter , selectionStart , and selectionEnd properties are responsible
for highlighting the selectedText section of the document.
Margin: The margin property is for specifying how far the text contents appear from the
edges of the text component.
Events: The actions and keymap properties describe which capabilities the text compo-
nent supports. In the case of the Action[ ] for the actions property, the capabilities are
a series of ActionListener implementations that you can associate with components for
event handling. For instance, instead of creating an ActionListener to perform cut, copy,
and paste operations, you find the appropriate Action within the actions property and
associate it with a component. The keymap property works in a similar manner, but it
associates Action implementations with specific keys. For instance, it contains a key
map entry for what to do when the PageUp key is pressed. The caretListeners property
allows you to discover the set of CaretListener objects observing the text component.
The dragEnabled setting describes if the component supports dragging text from within
the component. (For information about drag-and-drop support within Swing, see
Chapter 19.)
Scrollable interface: The properties preferredScrollableViewportSize ,
scrollableTracksViewportHeight , and scrollableTracksViewportWidth are
implementations of the respective Scrollable interface methods.
Search WWH ::




Custom Search