caretUpdatePolicy

Sets what the caret does when the document is edited somewhere other than where the caret sits.

DefaultCaret.ALWAYS_UPDATE carries the caret along with every edit whichever thread makes it, and keeps the caret visible - the policy a log view sits at the end of, so appended lines scroll into sight. DefaultCaret.NEVER_UPDATE leaves the caret at the offset it holds and does not scroll to keep it visible, so a view stays where the reader put it while text arrives above; a removal that shortens the document past that offset moves the caret to the end. DefaultCaret.UPDATE_WHEN_ON_EDT, the default, carries the caret along with edits made on the event dispatch thread and leaves it alone for edits made off it.

Requires a JTextComponent whose caret is a DefaultCaret - the caret a look and feel installs. A caret that arrives and is not a DefaultCaret fails as it is installed, as it would on a pass.

The policy belongs to the component, not to one caret, and removal puts it back, as caretBlinkRate describes for the rate.

Return

this modifier with the caret update policy declared on it.

Parameters

policy

the update constant written to the caret the component carries.

See also