javax.swing.text.DefaultStyledDocument
으로 확장되는 클래스에 간헐적 인 문제가 발생합니다. 이 문서는 프린터로 전송됩니다. 대부분의 경우 문서의 형식이 올바른 것처럼 보이지만 잠시 후에는 그렇지 않습니다. 서식의 일부 변경 사항이 적용되지 않은 것 같습니다. DefaultStyledDocument.styleChanged (스타일 스타일)가 적시에 실행되지 않을 수 있습니까?
DefaultStyledDocument.styleChanged(Style style)
코드를 살펴했다 :
/**
* Called when any of this document's styles have changed.
* Subclasses may wish to be intelligent about what gets damaged.
*
* @param style The Style that has changed.
*/
protected void styleChanged(Style style) {
// Only propagate change updated if have content
if (getLength() != 0) {
// lazily create a ChangeUpdateRunnable
if (updateRunnable == null) {
updateRunnable = new ChangeUpdateRunnable();
}
// We may get a whole batch of these at once, so only
// queue the runnable if it is not already pending
synchronized(updateRunnable) {
if (!updateRunnable.isPending) {
SwingUtilities.invokeLater(updateRunnable);
updateRunnable.isPending = true;
}
}
}
}
/**
* When run this creates a change event for the complete document
* and fires it.
*/
class ChangeUpdateRunnable implements Runnable {
boolean isPending = false;
public void run() {
synchronized(this) {
isPending = false;
}
try {
writeLock();
DefaultDocumentEvent dde = new DefaultDocumentEvent(0,
getLength(),
DocumentEvent.EventType.CHANGE);
dde.end();
fireChangedUpdate(dde);
} finally {
writeUnlock();
}
}
}
는 SwingUtilities.invokeLater(updateRunnable)
이 내가되기 전에 문서에 나타나는 내 서식 변경 믿을 수 없다는 의미가 아니라 invokeAndWait(updateRunnable)
보다,라고 사실을합니까 렌더링?
업데이트가 발생할 때까지 렌더링을 계속하지 않도록하는 방법이 있습니까?