Package javax.swing.text.html

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


  }

  protected void activateLink(int pos, JEditorPane html, int type) {
      Document doc = html.getDocument();
      if (doc instanceof HTMLDocument) {
    HTMLDocument hdoc = (HTMLDocument) doc;
    Element e = hdoc.getCharacterElement(pos);
    AttributeSet a = e.getAttributes();
    AttributeSet anchor =
        (AttributeSet) a.getAttribute(HTML.Tag.A);
    String href = (anchor != null) ?
        (String) anchor.getAttribute(HTML.Attribute.HREF) : null;
    boolean shouldExit = false;

    HyperlinkEvent linkEvent = null;
    if (href != null) {
        URL u;
        try {
      u = new URL(hdoc.getBase(), href);
        } catch (MalformedURLException m) {
      u = null;
        }

        if ((type == MOVE) && (!u.equals(currentUrl))) {
View Full Code Here

        return myPasswordModified;
    }

    private void initDebugTextPane() {
        HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
        HTMLDocument htmlDocument = new HTMLDocument();

        debugTextPane.setEditable(false);
        debugTextPane.setBackground(Color.WHITE);
        debugTextPane.setEditorKit(htmlEditorKit);
        htmlEditorKit.install(debugTextPane);
View Full Code Here

         *
         * @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

         *
         * @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

    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);

    setDocument(doc);
View Full Code Here

         *
         * @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

    }
    b.append("</ul>");
   
    JEditorPane text = new JEditorPane();
    text.setContentType("text/html; charset=UTF-8");
    HTMLDocument doc = (HTMLDocument) text.getDocument();
    doc.getStyleSheet().addRule("body { font-family: sans-serif;");
    text.setText(b.toString());
    JPanel msg = new JPanel();
    msg.setLayout(new BorderLayout());
    msg.setPreferredSize(new Dimension(500,500));
    msg.add(new JScrollPane(text),BorderLayout.CENTER);
View Full Code Here

    }
    b.append("</ul>");
   
    JEditorPane text = new JEditorPane();
    text.setContentType("text/html; charset=UTF-8");
    HTMLDocument doc = (HTMLDocument) text.getDocument();
    doc.getStyleSheet().addRule("body { font-family: sans-serif;");
    text.setText(b.toString());
    JPanel msg = new JPanel();
    msg.setLayout(new BorderLayout());
    msg.setPreferredSize(new Dimension(500,500));
    msg.add(new JScrollPane(text),BorderLayout.CENTER);
View Full Code Here

    tip.setEditable(false);
    tip.setMargin(new Insets(0, 0, 0, 0));
    final LinkMouseListener linkMouseListener = new LinkMouseListener();
    tip.addMouseListener(linkMouseListener);
    tip.addMouseMotionListener(linkMouseListener);
    final HTMLDocument document = (HTMLDocument) tip.getDocument();
    final StyleSheet styleSheet = document.getStyleSheet();
    styleSheet.removeStyle("p");
    styleSheet.removeStyle("body");
    styleSheet.addRule("p {margin-top:0;}\n");

    final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(tip);
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.