javax.swing.text.Documentpublic static interface NbDocument.WriteLockable
extends javax.swing.text.Document
| Modifier and Type | Method | Description |
|---|---|---|
void |
runAtomic(java.lang.Runnable r) |
Executes given runnable in lock mode of the document.
|
void |
runAtomicAsUser(java.lang.Runnable r) |
Executes given runnable in "user mode" does not allowing any modifications
to parts of text marked as guarded.
|
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeDocumentListener, removeUndoableEditListener, rendervoid runAtomic(java.lang.Runnable r)
By definition there should be only one locker at a time. Sample implementation, if you are extending AbstractDocument:
writeLock();
try {
r.run();
} finally {
writeUnlock();
}
r - runnable to run while lockedNbDocument.runAtomic(javax.swing.text.StyledDocument, java.lang.Runnable)void runAtomicAsUser(java.lang.Runnable r)
throws javax.swing.text.BadLocationException
r - runnable to run in user mode that will have exclusive access to modify the documentjavax.swing.text.BadLocationException - if a modification of guarded text occured
and that is why no changes to the document has been done.Built on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.