title: how to append css/html table in jtextpane
body: <p>I'm trying to 'append' an css/html table to a jtextpane. </p>
  
  <p>When I do: <strong>setText</strong> like this:</p>
  
  <pre><code>        jtextpane.setText(css)
  </code></pre>
  
  <p>I get the desired result [perfect!]:</p>
  
  <p><img src="https://i.stack.imgur.com/QKuaL.jpg" alt="enter image description here"></p>
  
  <p>but when I try to <strong>append</strong> the text to the jtextpane like this:</p>
  
  <pre><code>        int len = jtextpane.getDocument().getLength();
          jtextpane.setCaretPosition(len); 
          jtextpane.replaceSelection(css);
  </code></pre>
  
  <p>I get the html code embedded like this: 
  <img src="https://i.stack.imgur.com/nD0ZJ.jpg" alt="enter image description here"></p>
  
  <p>Q: how to append table's result (not the code) in the jtextPane? I assume I'm doing something wrong with the replaceSelection?! Thanks in advance </p>
  
  <p><strong>EDIT - additional information:</strong> </p>
  
  <ul>
  <li>To append all text information to the jtextpane I'm using the following static method:</li>
  </ul>
  
  <blockquote>
  <pre><code>public static void appendToPane(JTextPane jtextpane, String userText, Color color)
  {
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color);
    aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Myriad Pro");
    aset = sc.addAttribute(aset, StyleConstants.FontSize, 20);
    int len = jtextpane.getDocument().getLength();
    jtextpane.setCaretPosition(len);
    jtextpane.setCharacterAttributes(aset, false);
    jtextpane.replaceSelection(userText);
  }
  </code></pre>
  </blockquote>
  
  <ul>
  <li><p>on instantiation of the jtextpane I have:</p>
  
  <p>jtextpane.setContentType("text/html"); </p></li>
  <li><p>the original css string is this:</p></li>
  </ul>
  
  <blockquote>
    <p>
    
    table.imagetable {
        font-family: verdana,arial,sans-serif;
        font-size:11px;
        color:#333333;
        border-width: 1px;
        border-color: #999999;
        border-collapse: collapse;
    }
    table.imagetable th {
        background:#b5cfd2 url('cell-blue.jpg');
        border-width: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #999999;
    }
    table.imagetable td {
        background:#dcddc0 url('cell-grey.jpg');
        border-width: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #999999;
    }
    </p>
  </blockquote>