本文整理汇总了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;
}
示例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);
}
示例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;
}
示例4: insertUpdate
import javax.swing.event.DocumentEvent; //导入方法依赖的package包/类
public void insertUpdate(DocumentEvent evt) {
if (evt.getType() == DocumentEvent.EventType.REMOVE) { // undo
documentUndo(evt);
}
}
示例5: removeUpdate
import javax.swing.event.DocumentEvent; //导入方法依赖的package包/类
public void removeUpdate(DocumentEvent evt) {
if (evt.getType() == DocumentEvent.EventType.INSERT) { // undo
documentUndo(evt);
}
}
示例6: removeUpdate
import javax.swing.event.DocumentEvent; //导入方法依赖的package包/类
@Override
public void removeUpdate(DocumentEvent evt) {
if (evt.getType() == DocumentEvent.EventType.REMOVE) {
changedUpdate(evt);
}
}
示例7: insertUpdate
import javax.swing.event.DocumentEvent; //导入方法依赖的package包/类
@Override
public void insertUpdate(DocumentEvent evt) {
if (evt.getType() == DocumentEvent.EventType.INSERT) {
changedUpdate(evt);
}
}
示例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);
}
}
}
}
示例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();
}