aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/SynchronousHTMLEditorKit.java
blob: 7f02baa750e7417dcdeb7f9c00b15d29c6e1f01c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package io.github.moulberry.notenoughupdates.util;

import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.ImageView;
import javax.swing.text.html.HTMLEditorKit.HTMLFactory;

public class SynchronousHTMLEditorKit extends HTMLEditorKit {
    public SynchronousHTMLEditorKit() {
    }

    public Document createDefaultDocument() {
        HTMLDocument doc = (HTMLDocument)super.createDefaultDocument();
        doc.setAsynchronousLoadPriority(-1);
        return doc;
    }

    public ViewFactory getViewFactory() {
        return new HTMLFactory() {
            public View create(Element elem) {
                View view = super.create(elem);
                if (view instanceof ImageView) {
                    //((ImageView)view).setLoadsSynchronously(true);
                }

                return view;
            }
        };
    }


}