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);
}
}
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);
}
}
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 + "; " + "}");
}
}
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 + "; }");
}
}
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;
}
}
}
Aggregations