How to disable execution of HTML on table cell tooltip?

155 Views Asked by At

I'm using the PropertyTable from JIDE and I'm having a problem with tooltips when hovering over a table cell.

This table uses JTooltip and if I have on one cell a string containing html like this:

<b>BOLD</b>

When hovering over, the tooltip will display it like this:

BOLD

I tried reading the PropertyTable and JTooltip docs, but can't find anything. From what I've found in other questions here on stackoverflow, the JTooltip display the resulted html code if you enclose the string value like this:

<html><b>BOLD</b></html>

, but here it's not the case.

Is there any way to show the string value inside the tooltip? I can't seem to find anything in the docs of JTooltip.

Thank you!

1

There are 1 best solutions below

3
NoDataFound On

The tool tip is provided by the TableCellRenderer, which by default return the TOOL_TIP_TEXT_KEY client property. You may try to override the TableCellRenderer (which should be PropertyTableCellRenderer) and either:

  • Override TableCellRenderer::getToolTipText(MouseEvent)
  • Try to call setToolTip(String) in getTableCellRendererComponent

You could also try to overrides PropertyTable::getToolTipText(MouseEvent) but you'll have to re-implement quite a bit of logic.