Search in sources :

Example 1 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project languagetool by languagetool-org.

the class ResultAreaHelper method setHeader.

private void setHeader(String txt) {
    HTMLDocument d = (HTMLDocument) statusPane.getDocument();
    Element e = d.getElement(HEADER);
    try {
        d.setInnerHTML(e, "<p class=\"grayed\">" + txt + "</p>");
    } catch (BadLocationException ex) {
        Tools.showError(ex);
    } catch (IOException ex) {
        Tools.showError(ex);
    }
}
Also used : HTMLDocument(javax.swing.text.html.HTMLDocument) Element(javax.swing.text.Element) IOException(java.io.IOException) BadLocationException(javax.swing.text.BadLocationException)

Example 2 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project languagetool by languagetool-org.

the class ResultAreaHelper method setMain.

private void setMain(String html) {
    HTMLDocument d = (HTMLDocument) statusPane.getDocument();
    Element e = d.getElement(MAIN);
    try {
        d.setInnerHTML(e, html);
    } catch (BadLocationException ex) {
        Tools.showError(ex);
    } catch (IOException ex) {
        Tools.showError(ex);
    }
}
Also used : HTMLDocument(javax.swing.text.html.HTMLDocument) Element(javax.swing.text.Element) IOException(java.io.IOException) BadLocationException(javax.swing.text.BadLocationException)

Example 3 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project processing by processing.

the class DetailPanel method setTextStyle.

static void setTextStyle(JTextPane textPane, String fontSize) {
    Document doc = textPane.getDocument();
    if (doc instanceof HTMLDocument) {
        HTMLDocument html = (HTMLDocument) doc;
        StyleSheet stylesheet = html.getStyleSheet();
        stylesheet.addRule("body { " + "  margin: 0; padding: 0;" + "  font-family: " + Toolkit.getSansFontName() + ", Arial, Helvetica, sans-serif;" + "  font-size: 100%;" + "font-size: " + fontSize + "; " + "}");
    }
}
Also used : StyleSheet(javax.swing.text.html.StyleSheet) HTMLDocument(javax.swing.text.html.HTMLDocument) HTMLDocument(javax.swing.text.html.HTMLDocument) Document(javax.swing.text.Document)

Example 4 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project processing by processing.

the class DetailPanel method setForegroundStyle.

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
   * Sets coloring based on whether installed or not;
   * also makes ugly blue HTML links into the specified color (black).
   */
static void setForegroundStyle(JTextPane textPane, boolean installed, boolean selected) {
    Document doc = textPane.getDocument();
    if (doc instanceof HTMLDocument) {
        HTMLDocument html = (HTMLDocument) doc;
        StyleSheet stylesheet = html.getStyleSheet();
        // slightly grayed when installed
        String c = (installed && !selected) ? "#555555" : "#000000";
        stylesheet.addRule("body { color:" + c + "; }");
        stylesheet.addRule("a { color:" + c + "; }");
    }
}
Also used : StyleSheet(javax.swing.text.html.StyleSheet) HTMLDocument(javax.swing.text.html.HTMLDocument) HTMLDocument(javax.swing.text.html.HTMLDocument) Document(javax.swing.text.Document)

Example 5 with HTMLDocument

use of javax.swing.text.html.HTMLDocument in project jdk8u_jdk by JetBrains.

the class bug6636983 method checkComposedTextRun.

void checkComposedTextRun() {
    HTMLDocument d = (HTMLDocument) ep.getDocument();
    ElementIterator it = new ElementIterator(d.getDefaultRootElement());
    while (true) {
        Element e = it.next();
        if (e == null) {
            throw new RuntimeException("no composed text found");
        }
        AttributeSet a = e.getAttributes();
        if (a.isDefined(StyleConstants.ComposedTextAttribute)) {
            if (!AbstractDocument.ContentElementName.equals(a.getAttribute(StyleConstants.NameAttribute))) {
                throw new RuntimeException("AbstractDocument.ContentElementName.equals(a.getAttribute(StyleConstants.NameAttribute)) is false");
            }
            if (a.isDefined(SwingUtilities2.IMPLIED_CR)) {
                throw new RuntimeException("a.isDefined(SwingUtilities2.IMPLIED_CR) is true");
            }
            return;
        }
    }
}
Also used : HTMLDocument(javax.swing.text.html.HTMLDocument)

Aggregations

HTMLDocument (javax.swing.text.html.HTMLDocument)30 HTMLEditorKit (javax.swing.text.html.HTMLEditorKit)10 Element (javax.swing.text.Element)6 StyleSheet (javax.swing.text.html.StyleSheet)6 URL (java.net.URL)5 AttributeSet (javax.swing.text.AttributeSet)5 BadLocationException (javax.swing.text.BadLocationException)5 IOException (java.io.IOException)4 Document (javax.swing.text.Document)4 Style (javax.swing.text.Style)3 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 StringReader (java.io.StringReader)2 URLConnection (java.net.URLConnection)2 ArrayList (java.util.ArrayList)2 HyperlinkEvent (javax.swing.event.HyperlinkEvent)2 SimpleAttributeSet (javax.swing.text.SimpleAttributeSet)2 HTMLFrameHyperlinkEvent (javax.swing.text.html.HTMLFrameHyperlinkEvent)2 NlModel (com.android.tools.idea.uibuilder.model.NlModel)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1