1

何らかの理由で、HTML ページが画面に 100% 表示されるはずですが、タイミングの問題のように見えます。スクロールペインを削除して EditorPane だけを使用すると、問題なく動作します。

Javaアプレット画面を強制的に再描画/更新するには、以下にどのようなコードを追加する必要がありますか?すべての画像が実際に読み込まれるまで何とか待つことができますか? 現在、GUI でテキストが表示された後、画像が少し描画されます。
(ウィンドウを最小化して最大化すると、灰色が消え、欠落したテキストが表示されます。)

SynchronousHTMLEditorKit を m_editorPane.setEditorKitForContentType として使用します

private JEditorPane m_editorPane = new JTextPane();
private JScrollPane m_scrollPane = new JScrollPane();
....
JEditorPane.registerEditorKitForContentType( "text/html", "SynchronousHTMLEditorKit" );
m_editorPane.setEditorKitForContentType( "text/html", new SynchronousHTMLEditorKit() );
 m_editorPane.setPage(ResourceLoader.getURLforDataFile(file));
 m_scrollPane.getViewport().add(m_editorPane);
 m_scrollPane.validate();
 m_scrollPane.repaint(); <-- does not seem to solve this

add(m_scrollPane);
///    add(  m_editorPane) <-- this WORKS !!

SynchronousHTMLEditorKitと定義されている:

public class SynchronousHTMLEditorKit extends HTMLEditorKit {
    public Document createDefaultDocument(){
        HTMLDocument doc = (HTMLDocument)(super.createDefaultDocument());
        doc.setAsynchronousLoadPriority(-1); //do synchronous load
        return doc;
    }
4

2 に答える 2

1

追加後、検証呼び出しと再描画呼び出しを一番下に移動して、スクロールペインではなくコンテナーで呼び出してみてください

add(m_scrollPane);
validate();
repaint();
于 2009-04-21T13:10:29.467 に答える
0

を使用しないとどうなりますSynchronousHTMLEditorKitか? あなたのコードは、それがなくても完全に機能します。

于 2009-04-16T14:05:46.547 に答える