title: Inserting Images into a JTextPane Error
body: <p>I asked about this before, but, I decided to start a new thread with a SCCE, it compiles sucessfully but it doesn't insert the image. Can anyone troubleshoot as to why it does this? Thanks, Chris.</p>
  
  <p>Here is the full code:</p>
  
  <pre><code>package mathnotesplus;
  
  import java.awt.Dimension;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.SwingUtilities;
  import javax.swing.JPanel;
  import javax.swing.JTextPane;
  
  import javax.swing.JFrame;
  
  import javax.swing.JTree;
  import javax.swing.tree.DefaultMutableTreeNode;
  
  import javax.swing.*;
  import javax.swing.tree.*;
  import javax.swing.event.*;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.KeyEvent;
  import javax.swing.text.*;
  /**
   *
   * @author ChrisCates
   */
  public class MathNotesPlus extends JFrame implements TreeSelectionListener {
  
      /**
       * @param args the command line arguments
       */
      public MathNotesPlus() {
          setTitle("Math Notes Plus");
          setSize(800, 600);
          initUI();
      }
  
  
      JPanel panel;
      JTextPane textpane;
      JTree navigation;
      StyledDocument document;
  
      public void initUI(){
          //The panel.
          panel = new JPanel();
          //Textpane and JTree
          textpane = new JTextPane();
          navigation = new JTree();
          navigation.addTreeSelectionListener(this);
          //Preferred Resolution Size
          navigation.setPreferredSize(new Dimension(100, 600));
          textpane.setPreferredSize(new Dimension(700, 600));
  
          //Insertion of image into the document.
          try {
              document = (StyledDocument)textpane.getDocument();
              Style style = document.addStyle("StyleName", null);
              StyleConstants.setIcon(style, new ImageIcon("sigma.png"));
              document.insertString(document.getLength(), "ignored text", style);
          } catch (BadLocationException e){
              System.err.println("ERROR");
          }
  
          //Putting everything into the program.
          panel.add(navigation);
          panel.add(textpane);        
          add(panel);
          pack();
  
  
      }
  
      public static void main(String[] args) {
          // TODO code application logic here
          SwingUtilities.invokeLater(new Runnable() {
          public void run() {
              MathNotesPlus app = new MathNotesPlus();
                  app.setVisible(true);
              }
          });
      }
  
      @Override
      public void valueChanged(TreeSelectionEvent e) {
          throw new UnsupportedOperationException("Not supported yet.");
      }
  }
  </code></pre>