Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that you set tooltips on subcomponents of the component returned by your CellRenderer. To perform what you want, you should consider override <code>getToolTipText(MouseEvent e)</code> on the JTable. From the event, you can find on which row and column the mouse is, using:</p> <pre><code>java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); </code></pre> <p>From there you could then re-prepare the cell renderer, find which component is located at the mouse position and eventually retrieve its tooltip.</p> <p>Here is a snippet of how you could override JTable getToolTipText:</p> <pre><code>@Override public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); // Locate the renderer under the event location int hitColumnIndex = columnAtPoint(p); int hitRowIndex = rowAtPoint(p); if (hitColumnIndex != -1 &amp;&amp; hitRowIndex != -1) { TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex); Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex); Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false); component.setBounds(cellRect); component.validate(); component.doLayout(); p.translate(-cellRect.x, -cellRect.y); Component comp = component.getComponentAt(p); if (comp instanceof JComponent) { return ((JComponent) comp).getToolTipText(); } } // No tip from the renderer get our own tip if (tip == null) { tip = getToolTipText(); } return tip; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload