for testing purpose trying add little picture next each line of document code:
kit.inserthtml(doc, doc.getlength(), "<img src=file://res/picture.png>", 0, 0, html.tag.img);
my problem see this, no picture frame it:
i might have got pathing wrong should correct know:
this more code of method:
public void addtext(string text, boolean timestamp) { long timems = system.currenttimemillis(); date instant = new date(timems); simpledateformat sdf = new simpledateformat("hh:mm"); string time = sdf.format(instant); boolean shouldscroll = false; try { htmldocument doc = (htmldocument) getchat().getdocument(); htmleditorkit kit = (htmleditorkit) getchat().geteditorkit(); jscrollbar vsb = getchatscroller().getverticalscrollbar(); boundedrangemodel model = vsb.getmodel(); if (model.getextent() + model.getvalue() == model.getmaximum()) shouldscroll = true; kit.inserthtml(doc, doc.getlength(), timestamp ? time + ": " + text : text, 0, 0, null); kit.inserthtml(doc, doc.getlength(), "<img src=file://res/picture.png>", 0, 0, html.tag.img); if (shouldscroll) getchat().setcaretposition(doc.getlength()); } catch (ioexception | badlocationexception e) { e.printstacktrace(); } }
does know why can see little frame of picture, did forget something? in advance! if need more code let me know!
ok got done way:
string filename = getclass().getclassloader().getresource("res/kappa.png").tostring(); string pretag="<pre>filename : "+filename+"</pre>"; string imagetag="<img src=\""+filename+"\"/>"; kit.inserthtml(doc, doc.getlength(), pretag+imagetag, 0, 0, html.tag.img);
hope helps if have same problem :)
Comments
Post a Comment