How to Write a Caret Listener

Caret events occur when the caret — the cursor indicating the insertion point — in a text component moves or when the selection in a text component changes. The text component's document can initiate caret events when it inserts or removes text, for example. You can attach a caret listener to an instance of any JTextComponent subclass with the addCaretListener method.

Note

caretUpdate(CaretEvent) Called when the caret in the listened-to component moves or when the selection in the listened-to component changes.

« PreviousTrailNext »