62,614
社区成员
发帖
与我相关
我的任务
分享
selectedFile = chooser.getSelectedFile().getCanonicalFile();
//添加图片到jTextPane修改Doc
String img = selectedFile.getCanonicalPath();
if(img == null || (img != null && img.trim().length() == 0))
return ;
HTMLEditorKit kit = (HTMLEditorKit) getJTextPane().getEditorKit();
jTextPane.setEditorKit(kit);
img = img.replaceAll("\\\\", "/");
logger.info("img path ==" + img);
kit.insertHTML((HTMLDocument) jTextPane.getDocument(), jTextPane.getCaretPosition(), "<img src=\"" + img+ "\""+">",0,0,HTML.Tag.IMG);