Package javax.swing.text.html

Examples of javax.swing.text.html.HTMLDocument


            // TODO: cursor change doesn't seem to work; need JFrame
            // vs JDialog?
            parent.setCursor(Cursor
                .getPredefinedCursor(Cursor.WAIT_CURSOR));
            HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
            HTMLDocument doc = (HTMLDocument) pane.getDocument();
            doc.processHTMLFrameHyperlinkEvent(evt);
          } else {
            try {
              pane.setPage(e.getURL());
              parent.setCursor(null);
            } catch (IOException ex) {
View Full Code Here


                + defaultFont.getName()
                + "; font-size: "
                + defaultFont.getSize()
                + "pt;  }";
        if (area.getDocument() instanceof HTMLDocument) {
            HTMLDocument doc = (HTMLDocument)area.getDocument();
            try {
                doc.getStyleSheet().loadRules(new java.io.StringReader(stylesheet),
                        null);
            } catch (Exception e) {
                // TODO: handle exception
            }
        }
View Full Code Here

    // All standard LookAndFeels, even Nimbus (!), define Label.font.
    Font font = UIManager.getFont("Label.font");
    if (font == null) { // Try to make a sensible default
      font = new Font("SansSerif", Font.PLAIN, 12);
    }
    HTMLDocument doc = (HTMLDocument) textArea.getDocument();
    doc.getStyleSheet().addRule(
        "body { font-family: " + font.getFamily() + "; font-size: "
            + font.getSize() + "pt; }");

  }
View Full Code Here

  public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      JEditorPane pane = (JEditorPane)e.getSource();
      if (e instanceof HTMLFrameHyperlinkEvent) {
        HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
        HTMLDocument doc = (HTMLDocument)pane.getDocument();
        doc.processHTMLFrameHyperlinkEvent(evt);
      }

      else {
        try {
          pane.getEditorKit().createDefaultDocument();
View Full Code Here

* @author Oliver Hutchison
*/
public class SynchronousHTMLEditorKit extends HTMLEditorKit {

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

    // All standard LookAndFeels, even Nimbus (!), define Label.font.
    Font font = UIManager.getFont("Label.font");
    if (font == null) { // Try to make a sensible default
      font = new Font("SansSerif", Font.PLAIN, 12);
    }
    HTMLDocument doc = (HTMLDocument) textArea.getDocument();
    doc.getStyleSheet().addRule(
        "body { font-family: " + font.getFamily() + "; font-size: "
            + font.getSize() + "pt; }");

  }
View Full Code Here

                    }
                    // re-generate the doc
                    parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    pScript.generateDoc();
                    HTMLDocumentLoader loader = new HTMLDocumentLoader();
                    HTMLDocument doc;
                    try {
                        File tcDoc = pScript.getTestcaseDoc();
                        if (tcDoc != null) {
                            doc = loader.loadDocument(tcDoc.toURI().toURL());
                            setTestCaseInfo(doc);
View Full Code Here

        if (f == null) {
            testCasePane.setTestCaseInfo(null);
        } else {
            try {
                HTMLDocumentLoader loader = new HTMLDocumentLoader();
                HTMLDocument doc = loader.loadDocument(f.toURI().toURL());
                testCasePane.setTestCaseInfo(doc);
                if (activateSourceTab) {
                    testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.DOC_INDEX);
                }
            } catch (IOException ex) {
View Full Code Here

   */
  public static HTMLDocument createHtmlDocumentObject(
      Map<String, Object> style, double scale)
  {
    // Applies the font settings
    HTMLDocument document = new HTMLDocument();

    StringBuffer rule = new StringBuffer("body {");
    rule.append(" font-family: "
        + getString(style, mxConstants.STYLE_FONTFAMILY,
            mxConstants.DEFAULT_FONTFAMILIES) + " ; ");
    rule.append(" font-size: "
        + (int) (getInt(style, mxConstants.STYLE_FONTSIZE,
            mxConstants.DEFAULT_FONTSIZE) * scale) + " pt ;");

    String color = mxUtils.getString(style, mxConstants.STYLE_FONTCOLOR);

    if (color != null)
    {
      rule.append("color: " + color + " ; ");
    }

    int fontStyle = mxUtils.getInt(style, mxConstants.STYLE_FONTSTYLE);

    if ((fontStyle & mxConstants.FONT_BOLD) == mxConstants.FONT_BOLD)
    {
      rule.append(" font-weight: bold ; ");
    }

    if ((fontStyle & mxConstants.FONT_ITALIC) == mxConstants.FONT_ITALIC)
    {
      rule.append(" font-style: italic ; ");
    }

    if ((fontStyle & mxConstants.FONT_UNDERLINE) == mxConstants.FONT_UNDERLINE)
    {
      rule.append(" text-decoration: underline ; ");
    }

    String align = getString(style, mxConstants.STYLE_ALIGN,
        mxConstants.ALIGN_LEFT);

    if (align.equals(mxConstants.ALIGN_CENTER))
    {
      rule.append(" text-align: center ; ");
    }
    else if (align.equals(mxConstants.ALIGN_RIGHT))
    {
      rule.append(" text-align: right ; ");
    }

    rule.append(" } ");
    document.getStyleSheet().addRule(rule.toString());

    return document;
  }
View Full Code Here

          }

          try
          {
            HTMLEditorKit editorKit = new HTMLEditorKit();
            HTMLDocument document = (HTMLDocument) editorPane
                .getDocument();
            document.remove(start, (ende - start));
            editorKit.insertHTML(document, start, ((bold) ? "<b>"
                : "<i>") + text + ((bold) ? "</b>" : "</i>"),
                0, 0, (bold) ? HTML.Tag.B : HTML.Tag.I);
          }
          catch (Exception ex)
View Full Code Here

TOP

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

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.