How to use TextAction

action, java, jtextcomponent, key-bindings, swing

Solution

While composing this answer, I recalled a venerable `HTMLDocumentEditor` by Charles Bell that illustrates the typical usage of the subclasses found in `javax.swing.text.TextAction`. That editor is listed among the credits of `Metaphase Editor`. This related example showing actions found in `StyledEditorKit` follows the same approach. All such actions are suitable for Key Bindings, and all operate on the current selection maintained by the `Caret`, whenever possible.

Problem

What are the purposes of using TextAction from AbstractAction? and how to use it for the following: Caret Selection in the JTextComponents KeyBindings

Original source

Related problems