1

I wonder if it is possible to draw a BufferedImage to a regular tooltip.

As described here, an image may be placed into a tooltip by using HTML and an image element pointing to the URL of the image. So I tried to encode the BufferedImage in base64 like this and used the following HTML as tooltip text:

"<html><img src=\"data:image/png;base64," + Base64.encode(out.toByteArray()) + "\"></html>"

Unfortunately this doesn't work. Am I missing something or are the HTML capabilities of a tooltip too limited to support base64 encoded images? Is there any other way to display a dynamically generated image like a tooltip?

Community
  • 1
  • 1
Mouagip
  • 5,139
  • 3
  • 37
  • 52
  • Java's interpretation of HTML is simplistic. It does not support `data` based URLs. If you can write the image somewhere (e.g. the temp directory) see [this Q&A](http://stackoverflow.com/q/26795598/418556) for how to load it. – Andrew Thompson Nov 24 '14 at 11:12
  • @AndrewThompson Writing the image to disk is no option since it may change quickly. It doesn't *have* to use an actual tooltip, too; this was just the only idea I've been able to come up with so far. All I want is to display the image like it were a tooltip of some component. – Mouagip Nov 24 '14 at 11:33

0 Answers0