Examples of HTMLDocument


Examples of javax.swing.text.html.HTMLDocument

         *
         * @param content an HTML document
         */
        private void setDocumentContent(String content) {
       
            HTMLDocument doc = new HTMLDocument();
            try {
                doc.remove(0, doc.getLength());
            } catch (BadLocationException e) {
                e.printStackTrace();
            }
            doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
       
            try {
                htmlPane.read(new ByteArrayInputStream(content.getBytes()), doc);
            } catch (IOException e) {
                e.printStackTrace();
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

    editorPane = new JEditorPane();
    editorPane.setEditable(false);
    editorPane.setContentType("text/html");//NON-NLS
    editorPane.setText(getSystemInformationAsHTML());
    final HTMLDocument htmlDocument = (HTMLDocument) editorPane.getDocument();
    htmlDocument.getStyleSheet().addRule("body { font-family:sans-serif; }");//NON-NLS
    editorPane.setCaretPosition(0);

    super.init();
    getConfirmAction().putValue(Action.NAME, UtilMessages.getInstance().getString("SystemInformationDialog.Close"));
  }
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

    return true;
  }

  private boolean isInvisible(final javax.swing.text.Element textElement)
  {
    final HTMLDocument htmlDocument = (HTMLDocument) textElement.getDocument();
    final StyleSheet sheet = htmlDocument.getStyleSheet();
    final AttributeSet attr = computeStyle(textElement, sheet);
    final Object o = attr.getAttribute(CSS.Attribute.DISPLAY);
    if ("none".equals(String.valueOf(o)))
    {
      return true;
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

    return false;
  }

  private void configureStyle(final javax.swing.text.Element textElement, final Element result)
  {
    final HTMLDocument htmlDocument = (HTMLDocument) textElement.getDocument();
    final StyleSheet sheet = htmlDocument.getStyleSheet();
    final AttributeSet attr = computeStyle(textElement, sheet);
    parseBorderAndBackgroundStyle(result, sheet, attr);
    parseBoxStyle(result, attr);

    final Font font = sheet.getFont(attr);
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

    }

    public static void convertHtmlToText(Reader reader, Writer writer) throws IOException, BadLocationException {

        EditorKit kit = new HTMLEditorKit();
        HTMLDocument doc = new HTMLDocument();
        kit.read(reader, doc, 0);

        HTMLtoPlainTextWriter2 x = new HTMLtoPlainTextWriter2(writer, doc);
        x.write();
        writer.close();
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

    JTextPane html = new JTextPane();
    html.setContentType("text/html");
   
    html.setText("<p id = myOne>my text<i><b id = myTwo>myBold</b></i>xxx");

    HTMLDocument doc = (HTMLDocument) html.getDocument();

    Element el = doc.getElement("myOne");

    harness.check(true, el != null, "p with id must be found");
    harness.check(
                  el.getAttributes().getAttribute(StyleConstants.NameAttribute),
                  HTML.Tag.P, "Type must match");
    harness.check(!el.isLeaf());

    el = doc.getElement("myNone");
    harness.check(el == null, "should not be found");
   
  }
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

    URLConnection connection = url.openConnection();
    InputStream is = connection.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    HTMLEditorKit htmlKit = new HTMLEditorKit();
    HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
    HTMLEditorKit.Parser parser = new ParserDelegator();
    HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0);
    parser.parse(br, callback, true);

    ElementIterator iterator = new ElementIterator(htmlDoc);
    Element element;
    while ((element = iterator.next()) != null)
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

            JEditorPane welcomeTextView = new JEditorPane(url);
            welcomeTextView.setFocusable(false);
            welcomeTextView.setEditable(false);

            // Set font
            HTMLDocument doc = (HTMLDocument)welcomeTextView.getDocument();
            final Style style = doc.addStyle("normal", null);
            doc.setCharacterAttributes(0, doc.getLength(), style, false);

            welcomeText = welcomeTextView;
        } catch (IOException e)
        {
            String text = ResourceUtils.getString(ResourceIDs.LICENSE_WELCOME_TEXT);
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        final JEditorPane pane = (JEditorPane) e.getSource();

        if (e instanceof HTMLFrameHyperlinkEvent) {
          final HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
          final HTMLDocument doc = (HTMLDocument) pane.getDocument();
          doc.processHTMLFrameHyperlinkEvent(evt);
        } else {
          try {
            final String s = e.getURL().toExternalForm();
            pane.setPage(s);
          } catch (final Throwable t) {
            try {
              final Document doc = pane.getDocument();
              final String content = doc.getText(0, doc
                  .getLength());
              String searchString = " \n"
                + e.getDescription().substring(1);
              int pos = content.indexOf(searchString);
              if (pos == -1) {
View Full Code Here

Examples of javax.swing.text.html.HTMLDocument

    protected void applyTag(HTML.Tag tag) {
        Document doc = getDocument();
        if (!(doc instanceof HTMLDocument)) {
            return;
        }
        HTMLDocument hdoc = (HTMLDocument)doc;
        int start = getSelectionStart();
        int end = getSelectionEnd();

        Element element = hdoc.getParagraphElement(start);
        MutableAttributeSet newAttrs = new SimpleAttributeSet(element.getAttributes());
        newAttrs.addAttribute(StyleConstants.NameAttribute, tag);

        hdoc.setParagraphAttributes(start, end - start, newAttrs, true);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.