@Test public void testGetToolTipTextMouseEvent() { when(mouseEvent.getPoint()).thenReturn(new Point(10, 20)); table.setToolTipText("test"); assertEquals("test", table.getToolTipText(mouseEvent)); }
@Override public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int hitColumnIndex = columnAtPoint(p); int hitRowIndex = rowAtPoint(p); if ((hitColumnIndex != -1) && (hitRowIndex != -1)) { TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex); Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex); if (component instanceof JComponent) { Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false); p.translate(-cellRect.x, 0); MouseEvent newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger()); tip = ((JComponent) component).getToolTipText(newEvent); } } if (tip == null) tip = getToolTipText(); return tip; }
JTreeTable extends JTable { @Override public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int hitColumnIndex = columnAtPoint(p); int hitRowIndex = rowAtPoint(p); if ((hitColumnIndex != -1) && (hitRowIndex != -1)) { TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex); Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex); if (component instanceof JComponent) { Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false); p.translate(-cellRect.x, 0); MouseEvent newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger()); tip = ((JComponent) component).getToolTipText(newEvent); } } if (tip == null) tip = getToolTipText(); return tip; } }
JTreeTable extends JTable { @Override public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int hitColumnIndex = columnAtPoint(p); int hitRowIndex = rowAtPoint(p); if ((hitColumnIndex != -1) && (hitRowIndex != -1)) { TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex); Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex); if (component instanceof JComponent) { Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false); p.translate(-cellRect.x, 0); MouseEvent newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger()); tip = ((JComponent) component).getToolTipText(newEvent); } } if (tip == null) tip = getToolTipText(); return tip; } JTreeTable(final TreeTableModel treeTableModel); }
JTreeTable extends JTable { @Override public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int hitColumnIndex = columnAtPoint(p); int hitRowIndex = rowAtPoint(p); if ((hitColumnIndex != -1) && (hitRowIndex != -1)) { TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex); Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex); if (component instanceof JComponent) { Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false); p.translate(-cellRect.x, 0); MouseEvent newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger()); tip = ((JComponent) component).getToolTipText(newEvent); } } if (tip == null) tip = getToolTipText(); return tip; } JTreeTable(final TreeTableModel treeTableModel); @Override String getToolTipText(MouseEvent event); @Override void updateUI(); @Override int getEditingRow(); void setRowHeight(int rowHeight); JTree getTree(); }
JTreeTable extends JTable { @Override public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int hitColumnIndex = columnAtPoint(p); int hitRowIndex = rowAtPoint(p); if ((hitColumnIndex != -1) && (hitRowIndex != -1)) { TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex); Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex); if (component instanceof JComponent) { Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false); p.translate(-cellRect.x, 0); MouseEvent newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger()); tip = ((JComponent) component).getToolTipText(newEvent); } } if (tip == null) tip = getToolTipText(); return tip; } JTreeTable(final TreeTableModel treeTableModel); @Override String getToolTipText(MouseEvent event); @Override void updateUI(); @Override int getEditingRow(); void setRowHeight(int rowHeight); JTree getTree();  }