本文整理匯總了Java中javax.swing.text.StyledDocument.render方法的典型用法代碼示例。如果您正苦於以下問題:Java StyledDocument.render方法的具體用法?Java StyledDocument.render怎麽用?Java StyledDocument.render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.StyledDocument
的用法示例。
在下文中一共展示了StyledDocument.render方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DocLockedRun
import javax.swing.text.StyledDocument; //導入方法依賴的package包/類
public DocLockedRun(int type, StyledDocument doc, int intValue, boolean readLock) {
this.type = type;
this.intResult = intValue;
if (!readLock && (doc instanceof NbDocument.WriteLockable)) {
((NbDocument.WriteLockable) doc).runAtomic(this);
} else {
if (readLock && doc != null) {
doc.render(this);
} else {
// if the document is not one of "NetBeans ready"
// that supports locking we do not have many
// chances to do something. Maybe check for AbstractDocument
// and call writeLock using reflection, but better than
// that, let's leave this simple for now and wait for
// bug reports (if any appear)
run();
}
}
}
示例2: render
import javax.swing.text.StyledDocument; //導入方法依賴的package包/類
void render() {
StyledDocument d = mgr.getDoc();
Object prev = DOCUMENT.get();
try {
if (d != null) {
DOCUMENT.set(d);
d.render(this);
} else {
DOCUMENT.set(mgr);
this.run();
}
} finally {
DOCUMENT.set(prev);
}
}
示例3: getPosition
import javax.swing.text.StyledDocument; //導入方法依賴的package包/類
private static Position getPosition(final StyledDocument doc, final int offset) {
class Impl implements Runnable {
private Position pos;
public void run() {
if (offset < 0 || offset >= doc.getLength())
return ;
try {
pos = doc.createPosition(offset - NbDocument.findLineColumn(doc, offset));
} catch (BadLocationException ex) {
//should not happen?
Logger.getLogger(ComputeAnnotations.class.getName()).log(Level.FINE, null, ex);
}
}
}
Impl i = new Impl();
doc.render(i);
return i.pos;
}
示例4: testDeadlock49178
import javax.swing.text.StyledDocument; //導入方法依賴的package包/類
public void testDeadlock49178() throws Exception {
// open the document
final StyledDocument docu = support.openDocument();
// Perform a modification so that notifyModify() gets called as supposed by the test
// Otherwise notifyUnmodified() would not be called (there's no reason to call it in such case).
docu.insertString(0, "a", null);
// start closing it
Thread closing = new Thread(new Runnable() { public void run() {
support.close(false); // will block in notifyUnmodified()
closingDone = true;
}});
closing.start();
Thread processing = new Thread(new Runnable() {
boolean second = false;
public void run() {
if (!second) {
second = true;
docu.render(this);
// NbDocument.runAtomic(docu, this);
} else { // inside readLock
support.createPositionRef(0, Position.Bias.Forward);
processingDone = true;
}
}
});
synchronized(waitLock) {
while (!inWait) waitLock.wait();
}
processing.start();
Thread.sleep(1000);
synchronized(waitLock) {
shouldWait = false;
waitLock.notifyAll();
}
closing.join(10000);
processing.join(10000);
assertNull("No exception thrown", exception);
assertTrue("Closing thread finished", closingDone);
assertTrue("Processing thread finished", processingDone);
}