Package javax.swing.text.html

Examples of javax.swing.text.html.StyleSheet


    return new HTMLFactoryExtended();
  }

  public Document createDefaultDocument()
  {
    StyleSheet styles = getStyleSheet();
    StyleSheet ss = new StyleSheet();
    ss.addStyleSheet(styles);
    ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
    doc.setParser(getParser());
    doc.setAsynchronousLoadPriority(4);
    doc.setTokenThreshold(100);
    return doc;
View Full Code Here


    p.setContentType("text/html");
   
    Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: "+font.getFamily()+"; "+
                "font-size: " + font.getSize() + "pt; }";
        StyleSheet styles=((HTMLDocument)p.getDocument()).getStyleSheet();
        styles.addRule(bodyRule);
        return p;
  }
View Full Code Here

        setMargin(NO_MARGIN);
        updateUI();

        setEditorKit(new HTMLEditorKit());
        Font font = UIManager.getFont("Label.font");
        StyleSheet css = ((HTMLDocument)getDocument()).getStyleSheet();
        setOpaque(false);

        css.addRule("body {color : #" + getHexValue(UIManager.getColor("Label.foreground")) + " }");
        css.addRule("body {font-size : " + font.getSize() + "pt; }");
        css.addRule("body {font-family :" + font.getFontName() + "; }");
        setInverted(false);

        if (text != null) {
            setText(text);
        }
View Full Code Here

    public void setInverted(boolean inverted) {
        Document document = getDocument();
        if (document instanceof HTMLDocument) {
            HTMLDocument htmlDocument = (HTMLDocument)document;
            StyleSheet css = htmlDocument.getStyleSheet();
            css.addRule("a {color : #" + getHexValue(inverted ? getForeground() : COLOR_LINK) + " }");
            css.addRule("a:active {color : #" + getHexValue(inverted ? getForeground() : COLOR_LINK) + " }");
        }
    }
View Full Code Here

    public void setForeground(Color fg) {
        super.setForeground(fg);
        Document document = getDocument();
        if (document instanceof HTMLDocument) {
            HTMLDocument htmlDocument = (HTMLDocument)document;
            StyleSheet css = htmlDocument.getStyleSheet();
            css.addRule("body {color : #" + getHexValue(fg) + " }");
        }
    }
View Full Code Here

   */
  public EditorPaneLinkDetector() {

    HTMLEditorKit htmlkit = new HTMLEditorKit();

    StyleSheet styles = htmlkit.getStyleSheet();
    StyleSheet ss = new StyleSheet();

    ss.addStyleSheet(styles);

    ss.addRule("body {font-family:arial;font-size:12pt}");
    ss.addRule("p {font-family:arial;margin:2}");

    HTMLDocument doc = new HTMLDocLinkDetector(ss);

    setEditorKit(htmlkit);

View Full Code Here

     * Builds the style sheet used in the internal help browser
     *
     * @return the style sheet
     */
    protected StyleSheet buildStyleSheet() {
        StyleSheet ss = new StyleSheet();
        StringBuilder css = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(
                new InputStreamReader(
                        getClass().getResourceAsStream("/data/help-browser.css"), StandardCharsets.UTF_8
                )
        )) {
            String line = null;
            while ((line = reader.readLine()) != null) {
                css.append(line);
                css.append("\n");
            }
        } catch (Exception e) {
            Main.error(tr("Failed to read CSS file ''help-browser.css''. Exception is: {0}", e.toString()));
            Main.error(e);
            return ss;
        }
        ss.addRule(css.toString());
        return ss;
    }
View Full Code Here

        pane.setEditable(false);
        adaptForNimbus(pane);

        JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
        final Font f = UIManager.getFont("Label.font");
        final StyleSheet ss = new StyleSheet();
        ss.addRule((allBold ? "html" : "strong, b") + " {" + getFontRule(f) + "}");
        ss.addRule("a {text-decoration: underline; color: blue}");
        ss.addRule("h1 {" + getFontRule(GuiHelper.getTitleFont()) + "}");
        ss.addRule("ol {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: decimal}");
        ss.addRule("ul {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: disc}");
        kit.setStyleSheet(ss);
        pane.setEditorKit(kit);
    }
View Full Code Here

        setLayout(new BorderLayout());
        jepMessage = new JosmEditorPane("text/html", "");
        jepMessage.setOpaque(false);
        jepMessage.setEditable(false);
        Font f = UIManager.getFont("Label.font");
        StyleSheet ss = new StyleSheet();
        String rule = MessageFormat.format(
                "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
                f.getName(),
                f.getSize(),
                f.isBold() ? "bold" : "normal",
                        f.isItalic() ? "italic" : "normal"
        );
        rule = "body {" + rule + "}";
        rule = MessageFormat.format(
                "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
                f.getName(),
                f.getSize(),
                "bold",
                f.isItalic() ? "italic" : "normal"
        );
        rule = "strong {" + rule + "}";
        ss.addRule(rule);
        ss.addRule("a {text-decoration: underline; color: blue}");
        ss.addRule("ul {margin-left: 1cm; list-style-type: disc}");
        JosmHTMLEditorKit kit = new JosmHTMLEditorKit();
        kit.setStyleSheet(ss);
        jepMessage.setEditorKit(kit);

        add(jepMessage, BorderLayout.CENTER);
View Full Code Here

    jep.setMinimumSize(inSize);

    JFrame otherFrame = new JBidFrame(frameName);
    JPanel insidePanel = new JPanel(new BorderLayout());
    JScrollPane jsp = new JScrollPane(jep);
    StyleSheet sheet = hek.getStyleSheet();
    sheet.addRule(".smaller { font-size: 85%; }");
    sheet.addRule(".banner { font-size: 110%; }");
    sheet.addRule("body { font-family: Verdana, Geneva, Tahoma, sans-serif; }");
    sheet.addRule("ul li { margin-bottom: 4px; }");
    sheet.addRule(".changelog { color: #333333; margin-left: 20px; padding-left: 3px; background-color: #eeeeee; }");
    sheet.addRule(".changelog h1 { font-size: 110%; }");

    jep.setDocument(hek.createDefaultDocument());
    jep.setText(inSB.toString());

    jsp.getVerticalScrollBar().setValue(0);
View Full Code Here

TOP

Related Classes of javax.swing.text.html.StyleSheet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.