Jtextpane с HTMLEditorKit и HTMLDocument не отображает фотографию и не отображает поврежденную иконку, когда я сохраняю файл, и нахожу, что фотография загружена в созданный HTML-файл
try {
File f =im.file;
icon = new ImageIcon(f.getName());
int w = 300;
int h =300;
MutableAttributeSet attr = new SimpleAttributeSet();
attr.addAttribute(StyleConstants.NameAttribute,
HTML.Tag.IMG);
attr.addAttribute(HTML.Attribute.SRC, f.getAbsolutePath());
attr.addAttribute(HTML.Attribute.HEIGHT,
Integer.toString(h));
attr.addAttribute(HTML.Attribute.WIDTH,
Integer.toString(w));
int p = editor.getCaretPosition();
doc.insertString(p, " ", attr);
HTMLDocument docx = (HTMLDocument)editor.getDocument();
HTMLEditorKit kit=(HTMLEditorKit)editor.getEditorKit();
String filename = f.getAbsolutePath();
String preTag="filename is : "+filename+"
"; String imageTag =""; String s ="
"; // kit.insertHTML (doc, doc.getLength (), s, 0, 0, HTML.Tag.IMG); doc.insertString(editor.getCaretPosition (), "\ r \ n", editor.getInputAttributes ());} `` `` [см. сломанный значок [\] \ [1 \] [1] [1]:
https://i.stack.imgur.com/memDr.png