documentListener
Runs onDocumentChange for every change to the text component's document - an insertion, a removal and a change of attributes alike. Requires a JTextComponent target, and observes the document the component currently holds, following it when the component swaps one in - as a JEditorPane does when its content type changes.
onDocumentChange is read when the event fires, so writing a fresh lambda on every recomposition registers nothing again. To tell the three changes apart, declare them one by one instead.
Return
this chain with the document callback declared on it.
Parameters
receives the event, whose offset and length bound the affected range; writing to the document from it is refused while the change is being reported.
See also
Runs onInsert when text enters the text component's document, onRemove when text leaves it, and onChange when its attributes change. Requires a JTextComponent target, and follows the document the component holds across a swap.
Each lambda is read when its event fires, so writing a fresh one on every recomposition registers nothing again. A change left undeclared reports nowhere.
Declaring none at all is refused.
Return
this chain with the document callbacks declared on it.
Parameters
runs once the text is in the document.
runs once the text is gone, so the range the event bounds is the one it occupied.
runs when the attributes over a range change, not when the text itself does.
See also
Attaches a DocumentListener to the text component's document (document.addDocumentListener). Requires a JTextComponent target (JTextField, JTextArea, ...). The listener observes the document the component currently holds, following it when the component swaps one in.
Return
this chain with the document listener declared on it.
Parameters
attached by identity, so a remembered instance stays put while a fresh one on every pass is detached and re-added.