This method should be used to check whether the lastly performed Swing document modification was caused by user's typing. - Java Swing

Java examples for Swing:Swing HTML

Description

This method should be used to check whether the lastly performed Swing document modification was caused by user's typing.

Demo Code


//package com.java2s;
import javax.swing.event.DocumentEvent;

import javax.swing.text.Document;

public class Main {
    private static final Object TYPING_MODIFICATION_DOCUMENT_PROPERTY = new Object();

    /**/*from   www .j a v  a 2 s . co  m*/
     * @deprecated
     * @see #isTypingModification(Document)
     */
    public static boolean isTypingModification(DocumentEvent evt) {
        Boolean b = (Boolean) evt.getDocument().getProperty(
                TYPING_MODIFICATION_DOCUMENT_PROPERTY);
        return (b != null) ? b.booleanValue() : false;
    }

    /**
     * This method should be used to check whether
     * the lastly performed document modification was caused by user's typing.
     * <br/>
     * Certain functionality such as code completion or code templates
     * may benefit from that information. For example the java code completion
     * should only react to the typed "." but not if the same string was e.g.
     * pasted from the clipboard.
     *
     * @see #setTypingModification(Document, boolean)
     */
    public static boolean isTypingModification(Document doc) {
        Boolean b = (Boolean) doc
                .getProperty(TYPING_MODIFICATION_DOCUMENT_PROPERTY);
        return (b != null) ? b.booleanValue() : false;
    }
}

Related Tutorials