Hi everyone,

I am trying to insert a image into the jtextpane using the html document as the default document for the jtextpane. It seems that nothing happens when i try to insert the image from disk.

htmldoc - an instance of the HTMLDocument class
TextPane1 - an instance of the JTextPane class
mas - an instance of the MutableAttributeSet class

Here is my code

The file chooser class is ok so i did not include it here

File g = FileChooser3.getSelectedFile();
ImageIcon image1 = new ImageIcon(g.toString());

int w = image1.getIconWidth();
int h = image1.getIconHeight();

mas.addAttribute(StyleConstants.NameAttribute, HTML.Tag.IMG);
mas.addAttribute(HTML.Attribute.SRC, g.toString());
mas.addAttribute(HTML.Attribute.HEIGHT, Integer.toString(h));
mas.addAttribute(HTML.Attribute.WIDTH, Integer.toString(w));

try
{
int p = TextPane1.getCaretPosition();
htmldoc.insertString(p, " ", mas);
}

catch(Exception e)
{
}

The above code compiles without errors but does not seem to work.
Can someone tell me how to insert an image into a html document in the jtextpane or show me an example of inserting icons in a html document

Thank You

Yours Sincerely

Richard West