Package javax.swing.text

Examples of javax.swing.text.DocumentFilter


        if (!(doc instanceof AbstractDocument)) {
            throw new IllegalArgumentException("Specified document cannot be filtered!");
        }

        // set up the filter.
        ((AbstractDocument) doc).setDocumentFilter(new DocumentFilter() {
            @Override public void remove (FilterBypass fb, int offset, int length)
                throws BadLocationException
            {
                if (replaceOk(offset, length, "")) {
                    fb.remove(offset, length);
View Full Code Here


        // create a document filter which enforces the restrictions on
        // what text may be entered. This is similar to the filter
        // that is configured in SwingUtil.setDocumentHelpers, only the
        // remove operation is modified to do the sneaky highlighting we do.
        final IntDocument doc = (IntDocument) getDocument();
        doc.setDocumentFilter(new DocumentFilter() {
            @Override public void remove (FilterBypass fb, int offset, int length)
                throws BadLocationException
            {
                String current = doc.getText(0, doc.getLength());
                String potential = current.substring(0, offset) +
View Full Code Here

TOP

Related Classes of javax.swing.text.DocumentFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.