Chapter 22. Carets, Highlighters, and Keymaps
Like some of the other Swing components (
for example), the text components allow you to do a certain amount of
customization without actually implementing your own look-and-feel.
Certain aspects of these components’ behavior and appearance
can be modified directly using
set() methods on
JTextComponent. In addition, with the more
powerful text components (
anything that extends it, including
are able to control the
View objects created to
Element of the
In this chapter, we’ll concentrate on the classes and
interfaces related to modifying text components without dealing with
View objects. This will include an explanation of
carets, highlighters, and keymaps. Chapter 23, will
examine the various
JTextComponent UI Properties
has three UI-related properties
that you can access and modify directly. These properties are defined
by the following interfaces:
Defines how the cursor is displayed. This includes the size and shape of the cursor, the blink rate (if any), etc.
Defines how selected text is highlighted. Typically this is done by painting a solid rectangle “behind” the text, but this is up to the implementation of this interface. Highlighter also defines two inner-interfaces that we’ll look at.
Actions performed when certain keys are pressed. For example, pressing CTRL-C may copy some text and CTRL-V may ...