本文整理汇总了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);
}