In my JavaFX app I have a TableView
with multiple columns, one of which displays data in a graphical form. To do this I have created a CanvasCell
object that creates and manages its own Canvas
to deal with the drawing. The drawing part works just fine.
I'd now like to put Tooltips
over some regions within the Canvas
/Cell
. There may be multiple Tooltips
per Cell
(which prevents me from adding the Tooltip
at the Cell
level) and they should only trigger in specific regions of the graph. However, I'm not managing to get it functioning at all. I don't seem to understand the interactions of Display Node hierarchy well enough (read "at all") to be able to place the Tooltip
anywhere where it will actually work.
Documentation for JavaFX is sparse and Google + SO has come up blank for all searches that I've tried. Is there anyone who knows how to do this sort of thing or should I just write it off as "not an option" for now.
For info, the CanvasCell
calls a draw()
function inside an extended Canvas
object on updateItem()
. The code in which I've tried to create a Tooltip
sits inside that draw()
function and looks like:
Rectangle rect = new Rectangle(leftVal, topVal, width, height);
gc.fillRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
Tooltip tooltip = new Tooltip("Tooltip Text");
Tooltip.install(rect, tooltip);
but that code was written more in hope than anything else and doesn't generate anything useful in the interface.
If someone can point me in the right direction, I will be very grateful.