Tooltips in XYImageAnnotations

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
swperman
Posts: 4
Joined: Mon Aug 13, 2007 9:09 pm

Tooltips in XYImageAnnotations

Post by swperman » Thu Sep 20, 2007 4:36 pm

Is there a way to show tooltips (small box with text) when you hover the mouse over the image? Or maybe making the image clickable, then opening a small window when user clicks it...? Is it possible?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Sep 20, 2007 4:38 pm

The XYImageAnnotation class inherits a setToolTipText() method from AbstractXYAnnotation.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

swperman
Posts: 4
Joined: Mon Aug 13, 2007 9:09 pm

Post by swperman » Thu Sep 20, 2007 5:11 pm

Just one more quick question... apparently setToolTipText() method doesn't support line breaks. I tried both "\n" and System.getProperties("line.separator") and none worked. Is there a way to show multiple lines inside the tooltip? thanks again =)

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Thu Sep 20, 2007 6:46 pm

JFreeChart uses the standard Swing tooltip support. Tooltips (like every other Swing text component) can render a subset of html. This will do what you want:

Code: Select all

setToolTipText("<html><body>line1<br>line2</body></html>");

Locked