public String getToolTipText(MouseEvent e) { int r = rowAtPoint(e.getPoint()); int c = columnAtPoint(e.getPoint()); Object value; try { value = getValueAt(r, c); } catch (Exception e1) { // If we encounter a row that should not actually exist and therefore // has a null value. Just return an empty string for the tooltip. return ""; } String tooltipValue = null; if (value instanceof JLabel) { tooltipValue = ((JLabel) value).getToolTipText(); } if (value instanceof JLabel && tooltipValue == null) { tooltipValue = ((JLabel) value).getText(); } else if (value != null && tooltipValue == null) { tooltipValue = value.toString(); } else if (tooltipValue == null) { tooltipValue = ""; } return GraphicUtils.createToolTip(tooltipValue); }