documentFilter
Installs filter on the text component's document so it can inspect, reject, or rewrite every insert, remove, and replace before it is applied. A null filter clears any filter the modifier previously installed. Requires a JTextComponent target whose document is an AbstractDocument. A JFormattedTextField is rejected: its document filter belongs to its formatter, which returns it from JFormattedTextField.AbstractFormatter.getDocumentFilter and reinstalls it whenever the field reformats.
The filter follows the component across document swaps: replacing the component's document - as a JEditorPane does when it switches content type - moves the filter onto the new document so it stays active. Every document is handed back the filter it carried before this one arrived on it: the document being left on a swap, and the current one once the declaration goes.
TextField(
value = digits,
onValueChange = { digits = it },
modifier = SwingModifier.documentFilter(DigitsOnlyFilter),
)Return
this modifier with the document filter declared on it.
Parameters
the DocumentFilter to apply, or null to remove the installed filter.