How to use TextAction

From Java Swing 2nd Edition:

All text components share a set of default Actions. Each of these
Actions are instances of TextAction by default. JTextComponent
provides a private static EditorKit which consists of a set of four
pre-built TextActions shared by all text components through the use of
a default Keymap instance.

JTextComponent maintains a private reference to the text component
that most recently had the keyboard focus. TextActions are designed to
take advantage of this, and each TextAction will operate on this
component when it’s invoked in the event that the source of the
invoking event is not a text component.

Here are some examples that implement TextAction:

Custom Editing Command

Finding Word Boundaries

Leave a Comment