Class DocumentUtil.LengthLimitedDocument

  • All Implemented Interfaces:
    javax.swing.text.Document
    Enclosing class:
    DocumentUtil

    private static class DocumentUtil.LengthLimitedDocument
    extends DocumentUtil.PassthroughDocument
    A wrapper document that prevents the user from typing more than a specified number of characters.
    • Field Detail

      • maxLength_

        private int maxLength_
    • Constructor Detail

      • LengthLimitedDocument

        public LengthLimitedDocument​(javax.swing.text.Document document,
                                     int maxLength)
        Create an instance
        Parameters:
        document - The document to wrap
        maxLength - The maximum number of characters that can be entered into this document
    • Method Detail

      • insertString

        public void insertString​(int offset,
                                 java.lang.String string,
                                 javax.swing.text.AttributeSet attributeSet)
                          throws javax.swing.text.BadLocationException
        Specified by:
        insertString in interface javax.swing.text.Document
        Overrides:
        insertString in class DocumentUtil.PassthroughDocument
        Throws:
        javax.swing.text.BadLocationException