當前位置: 首頁>>代碼示例>>Java>>正文


Java DocumentEvent.getType方法代碼示例

本文整理匯總了Java中javax.swing.event.DocumentEvent.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java DocumentEvent.getType方法的具體用法?Java DocumentEvent.getType怎麽用?Java DocumentEvent.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.event.DocumentEvent的用法示例。


在下文中一共展示了DocumentEvent.getType方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: appendEvent

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
/**
 * Get string representation of an offset for debugging purposes
 * in form "offset[line:column]". Both lines and columns start counting from 1
 * like in the editor's status bar. Tabs are expanded when counting the column.
 *
 * @param sb valid string builder to which text will be appended or null in which case
 *  the method itself will create a string builder and it will return it.
 * @param evt non-null document event.
 * @return non-null string builder to which the description was added.
 * @since 1.27
 */
public static StringBuilder appendEvent(StringBuilder sb, DocumentEvent evt) {
    if (sb == null) {
        sb = new StringBuilder(100);
    }
    DocumentEvent.EventType type = evt.getType();
    sb.append(type).append(", ");
    appendOffset(sb, evt.getDocument(), evt.getOffset());
    sb.append(", l=").append(evt.getLength());
    // Possibly append the modification text
    String modText;
    if ((modText = getModificationText(evt)) != null) {
        sb.append(", modText=\"");
        CharSequenceUtilities.debugText(sb, modText);
        sb.append('"');
    }
    return sb;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:DocumentUtilities.java

示例2: checkEventsEqual

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void checkEventsEqual(DocumentEvent testEvent) {
    if (masterEvent.getOffset() != testEvent.getOffset()) {
        fail("masterEvent.getOffset()=" + masterEvent.getOffset()
            + " != testEvent.getOffset()=" + testEvent.getOffset());
    }
    if (masterEvent.getLength() != testEvent.getLength()) {
        fail("masterEvent.getLength()=" + masterEvent.getLength()
            + " != testEvent.getLength()=" + testEvent.getLength());
    }
    if (masterEvent.getType() != testEvent.getType()) {
        fail("masterEvent.getType()=" + masterEvent.getType()
            + " != testEvent.getType()=" + testEvent.getType());
    }
    DocumentEvent.ElementChange masterChange = masterEvent.getChange(masterDoc.getDefaultRootElement());
    DocumentEvent.ElementChange testChange = testEvent.getChange(testDoc.getDefaultRootElement());
    checkElementChangesEqual(masterChange, testChange);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:PlainDocumentCompatibilityRandomTest.java

示例3: fixOffset

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
/**
 * Fix the given offset according to the performed modification.
 * 
 * @param offset >=0 offset in a document.
 * @param evt document event describing change in the document.
 * @return offset updated by applying the document change to the offset.
 */
public static int fixOffset(int offset, DocumentEvent evt) {
    int modOffset = evt.getOffset();
    if (evt.getType() == DocumentEvent.EventType.INSERT) {
        if (offset >= modOffset) {
            offset += evt.getLength();
        }
    } else if (evt.getType() == DocumentEvent.EventType.REMOVE) {
        if (offset > modOffset) {
            offset = Math.max(offset - evt.getLength(), modOffset);
        }
    }
    return offset;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:DocumentUtilities.java

示例4: insertUpdate

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
public void insertUpdate(DocumentEvent evt) {
    if (evt.getType() == DocumentEvent.EventType.REMOVE) { // undo
        documentUndo(evt);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:StatusBar.java

示例5: removeUpdate

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
public void removeUpdate(DocumentEvent evt) {
    if (evt.getType() == DocumentEvent.EventType.INSERT) { // undo
        documentUndo(evt);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:StatusBar.java

示例6: removeUpdate

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
@Override
public void removeUpdate(DocumentEvent evt) {
    if (evt.getType() == DocumentEvent.EventType.REMOVE) {
        changedUpdate(evt);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:ModRootElement.java

示例7: insertUpdate

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
@Override
public void insertUpdate(DocumentEvent evt) {
    if (evt.getType() == DocumentEvent.EventType.INSERT) {
        changedUpdate(evt);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:ModRootElement.java

示例8: updateDamage

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
@Override
   protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) {
       Document doc = getDocument();
       if (!(doc instanceof Document)) {
           super.updateDamage(changes, a, f);
           return;
       }
       if (longestLineLength == -1) {
           calcLongestLineLength();
       }
Component host = getContainer();
updateMetrics();        
Element elem = getElement();
DocumentEvent.ElementChange ec = changes.getChange(elem);
Element[] added = (ec != null) ? ec.getChildrenAdded() : null;
Element[] removed = (ec != null) ? ec.getChildrenRemoved() : null;
if (((added != null) && (added.length > 0)) || 
    ((removed != null) && (removed.length > 0))) {
    // lines were added or removed...
    if (added != null) {
	for (int i = 0; i < added.length; i++) {
	    int w = getLineWidth(added[i]);
	    if (w > longestLineLength) {
		longestLineLength = w;
		longestLine = added[i];
	    }
	}
    }
    if (removed != null) {
	for (int i = 0; i < removed.length; i++) {
	    if (removed[i] == longestLine) {
		calcLongestLineLength();
		break;
	    }
	}
    }
    preferenceChanged(null, true, true);
    host.repaint();
} else {
    Element map = getElement();
    int line = map.getElementIndex(changes.getOffset());
    damageLineRange(line, line, a, host);
    if (changes.getType() == DocumentEvent.EventType.INSERT) {
	// check to see if the line is longer than current longest line.
	Element e = map.getElement(line);
               int lineLen = getLineWidth(e);
	if (e == longestLine) {
	    preferenceChanged(null, true, false);
	} else if (lineLen > longestLineLength) {
                   longestLineLength = lineLen;
	    longestLine = e;
	    preferenceChanged(null, true, false);
	}
    } else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
	if (map.getElement(line) == longestLine) {
	    // removed from longest line... recalc
	    calcLongestLineLength();
	    preferenceChanged(null, true, false);
	}			
    }
}
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:63,代碼來源:ExtPlainView.java

示例9: updateChildren

import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
/**
 * Update the child views in response to a
 * document event.
 */
void updateChildren(DocumentEvent e, Shape a) {

	Element elem = getElement();
	DocumentEvent.ElementChange ec = e.getChange(elem);

	// This occurs when syntax highlighting only changes on lines
	// (i.e. beginning a multiline comment).
	if (e.getType()==DocumentEvent.EventType.CHANGE) {
		//System.err.println("Updating the damage due to a CHANGE event...");
		// FIXME:  Make me repaint more intelligently.
		getContainer().repaint();
		//damageLineRange(startLine,endLine, a, host);
	}

	else if (ec != null) {

		// the structure of this element changed.
		Element[] removedElems = ec.getChildrenRemoved();
		Element[] addedElems = ec.getChildrenAdded();
		View[] added = new View[addedElems.length];

		for (int i = 0; i < addedElems.length; i++) {
			added[i] = new WrappedLine(addedElems[i]);
		}
		//System.err.println("Replacing " + removedElems.length +
		// " children with " + addedElems.length);
		replace(ec.getIndex(), removedElems.length, added);

		// should damge a little more intelligently.
		if (a != null) {
			preferenceChanged(null, true, true);
			getContainer().repaint();
		}

	}

	// update font metrics which may be used by the child views
	updateMetrics();

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:45,代碼來源:WrappedSyntaxView.java


注:本文中的javax.swing.event.DocumentEvent.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。