Package swingtree

Class TextReplaceDelegate


public final class TextReplaceDelegate extends AbstractTextComponentDelegate
A delegate object for the Action lambda passed to the UIForAnyTextComponent.onTextReplace(Action) method, which is used to register a listener for text replacement events.
This delegate provides useful context information to the action listener, such as the text component itself, the DocumentFilter.FilterBypass object that can be used to replace text in the document, the offset at which the text is to be replaced and the length of the text to be replaced.
  • Method Details

    • getText

      public String getText()
      Exposes the text to insert where an empty string indicates no text is to be inserted.
      Returns:
      The text to be inserted or an empty String indicating that no text is to be inserted. Null is never returned.
    • getReplacementText

      public String getReplacementText()
      Exposes the text to be replaced or an empty String indicating that no text is to be replaced. Null is never returned.
      Returns:
      The text to be removed.
    • getAttributeSet

      public AttributeSet getAttributeSet()
      Exposes the attribute set of the text to be replaced. It is a collection of unique attributes in the form of a read-only, immutable interface. A single attribute is basically a key and a value assigned to the key. The collection may represent something like a style run, a logical style, etc. These are generally used to describe features that will contribute to some graphical representation such as a font.

      See DocumentFilter.replace(DocumentFilter.FilterBypass, int, int, String, AttributeSet) for more information about the origin of this attribute.

      Returns:
      The attribute set of the text to be inserted.