Package javax.swing.text.html

Examples of javax.swing.text.html.HTMLDocument


    }

    private TextFragment[] split(final String text) {
      final LinkedList<TextFragment> htmlFragments = new LinkedList<TextFragment>();
      final HTMLEditorKit kit = new HTMLEditorKit();
      final HTMLDocument doc = new HTMLDocument();
      final StringReader buf = new StringReader(text);
      try {
        kit.read(buf, doc, 0);
        final Element parent = getParentElement(doc);
        split(doc, parent, htmlFragments, 0);
View Full Code Here


  sender = "<font color=red><b>"+comm.getMsgFrom()+":</font>";
  if(null == comm.getMsgFrom()) {
      sender = "";
  }
  s = "<font color=black><b> " + s + "<b></font>";
  HTMLDocument doc = (HTMLDocument) getDocument();
  HTMLEditorKit kit = (HTMLEditorKit) getEditorKit();
  System.out.println("message befor rep " + s);
  s = replaceImage(":\\)", s, capp.getSmileyPath());
  s = replaceImage(":\\(", s, capp.getSaddyPath());
  s = replaceImage(":\\$", s, capp.getWinkingPath());
  s = replaceImage(":p", s, capp.getTonguePath());
  s = replaceImage(":o", s, capp.getOhPath());
  s = replaceImage(":\\?", s, capp.getQuestionPath());
 
  String msg = sender + pvt + s;
  try {
      kit.insertHTML(doc, doc.getLength(), msg,
        0, 0, HTML.Tag.FONT);
      setCaretPosition(doc.getLength());
      capp.playRecieveSound();
  } catch (Throwable t) {
  }

    }
View Full Code Here

     *
     * @param s
     *  the error message
     */
    public void error(String s) {
  HTMLDocument doc = (HTMLDocument) getDocument();
  HTMLEditorKit kit = (HTMLEditorKit) getEditorKit();
  try {
      kit.insertHTML(doc, doc.getLength(),
        "<font color=#CC0000><b> " + s + "<b><br></font>",
        0, 0, HTML.Tag.FONT);
      setCaretPosition(doc.getLength());
  } catch (Throwable t) {
  }
    }
View Full Code Here

            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

    if(!textR.contains(p))
      return null;
    int x = (int) (p.x / getZoom());
    int y = (int) (p.y / getZoom());
    final int pos = view.viewToModel(x, y, textR);
    final HTMLDocument document = (HTMLDocument) view.getDocument();
    final String linkURL = HtmlUtils.getURLOfExistingLink(document, pos);
    return linkURL;
  }
View Full Code Here

        LOG.debug(Messages.getString("EditorDataLoader.0"));   //$NON-NLS-1$
    
     try {

            // get the editor document
       HTMLDocument doc = (HTMLDocument)editor.getDocument();
      
        if (LOG.isDebugEnabled())
          LOG.debug(Messages.getString("EditorDataLoader.1")); //$NON-NLS-1$
           
       //set the codebase so images relative to the codebase are properly loaded   
       doc.setBase(new URL(url));
       doc.putProperty(Document.StreamDescriptionProperty,url);
           
            // open an inpustream from the web service/page
       InputStream in = DataUtils.getInputStream(url, params, name);  
       editor.setText(""); //$NON-NLS-1$
           
View Full Code Here

                   JEditorPane pane = (JEditorPane) event.getSource();
                    
                     // check if the event was an internal frame link event
                   if (event instanceof HTMLFrameHyperlinkEvent) {
                       HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)event;
                       HTMLDocument doc = (HTMLDocument)pane.getDocument();
                       doc.processHTMLFrameHyperlinkEvent(evt);
                   } else {
                         // otherwise get the URL that was clicked
                     url = event.getURL().toString();
                    
                     javax.swing.text.Element el = event.getSourceElement();
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" +
            "; color: " + getHexString(fg) + "; }");

  }
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 {
          backwardStack.push(pane.getPage());
          navigationCallback.navigateBackwardStateChanged(true);
          forwardStack.clear();
          navigationCallback.navigateForwardStateChanged(false);
View Full Code Here

     * @param control   text control.
     * @param styleName style name.
     */
    public static void installTextStyle(JEditorPane control, String styleName)
    {
        HTMLDocument doc = (HTMLDocument)control.getDocument();
        doc.setCharacterAttributes(0, control.getDocument().getLength(),
            doc.getStyle(styleName), false);
    }
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.