Package javax.swing.text.html

Examples of javax.swing.text.html.HTMLDocument


        String txt = MessageFormat.format("<a href=\"{0}\">{1}</a>", link, title);

        Document document = editor.getDocument();
        if (document instanceof HTMLDocument)
        {
            HTMLDocument htmlDocument = (HTMLDocument)document;
            int offset = editor.getSelectionStart();

            HTMLEditorKit kit = (HTMLEditorKit)editor.getEditorKit();
            try
            {
                htmlDocument.remove(offset, editor.getSelectionEnd() - offset);
                kit.insertHTML(htmlDocument, offset, txt, 0, 0, HTML.Tag.A);
            } catch (Throwable e)
            {
                LOG.log(Level.WARNING, "Failed to insert link", e);
            }
View Full Code Here


    }

    private void initTextStyle(IArticle article, IArticleDisplayConfig config)
    {
        // Create new style for article and init it with default style settings
        HTMLDocument doc = (HTMLDocument)tfText.getDocument();
        doc.setBase(article.getLink());
        Style def = doc.getStyle("default");
        doc.addStyle(TEXT_STYLE_NAME, def);
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, config.getTitleFont(article.isRead()));

        doc = (HTMLDocument)tfFullText.getDocument();
        doc.setBase(article.getLink());
        def = doc.getStyle("default");
        doc.addStyle(TEXT_STYLE_NAME, def);
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, config.getTextFont());
    }
View Full Code Here

            // Otherwise under some conditions the height will be equal to zero and
            // no text will be displayed.
            if (SystemUtils.IS_OS_MAC) text = "<p id='start'>" + text;
        }

        HTMLDocument doc = (HTMLDocument)tfText.getDocument();
        doc.putProperty(Document.StreamDescriptionProperty, ((NetworkFeed) article.getFeed()).getXmlURL());

        tfText.setText(text);
        UifUtilities.installTextStyle(tfText, TEXT_STYLE_NAME);

        if (link != null)
View Full Code Here

    {
        Font dateFont = config.getDateFont();
        lbDate.setFont(dateFont);
        lnReply.setFont(config.getTextFont());

        HTMLDocument doc = (HTMLDocument)tfText.getDocument();
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, config.getTitleFont(article.isRead()));
        UifUtilities.installTextStyle(tfText, TEXT_STYLE_NAME);

        doc = (HTMLDocument)tfFullText.getDocument();
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, config.getTextFont());
View Full Code Here

        selected = false;
        focused = false;

        // Create new style for article and init it with default style settings
        HTMLDocument doc = (HTMLDocument)tpText.getDocument();
        doc.setBase(article.getLink());
        Style def = doc.getStyle("default");
        doc.addStyle(TEXT_STYLE_NAME, def);
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, config.getTextFont());

        // Set base URL to resolve relative links
        final IFeed feed = article.getFeed();
        if (feed instanceof NetworkFeed)
        {
            doc.putProperty(Document.StreamDescriptionProperty, ((NetworkFeed)feed).getXmlURL());
        }

        setupLayout();
        setBorder(new UpDownBorder(COLOR_BORDER_LINE));
View Full Code Here

  public ChatComponent() {
    super(new BorderLayout());
   
    chatArea = new JEditorPane();
    chatArea.setEditorKit(new HTMLEditorKit());
    chatArea.setDocument(new HTMLDocument());
    chatArea.setEditable(false);
    chatArea.addHyperlinkListener(this);
    this.add(new VerticalJScrollPane(chatArea), BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new BorderLayout());
View Full Code Here

    }
    outgoingChatField.setText("");
  }
 
  public void addLine(String line) {
    HTMLDocument chatDocument = (HTMLDocument) chatArea.getDocument();
    HTMLEditorKit chatKit = (HTMLEditorKit) chatArea.getEditorKit();
    try {
      chatKit.insertHTML(chatDocument, chatDocument.getLength(), line, 0, 0, null);
    } catch (BadLocationException | IOException e) {
      e.printStackTrace();
    }
    chatArea.setCaretPosition(chatArea.getDocument().getLength());
  }
View Full Code Here

    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) {
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.setPage(e.getURL());
          } catch (Throwable t) {
            t.printStackTrace();
View Full Code Here

      if (! url.equals(url2)) { prevpage.add(url); }
    }
   help_frame.enableButtons();
   if (e instanceof HTMLFrameHyperlinkEvent) {
      HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
      HTMLDocument doc = (HTMLDocument)pane.getDocument();
      doc.processHTMLFrameHyperlinkEvent(evt);
    }
   else {
      try {
         pane.setPage(e.getURL());
       }
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.