There are several cases in which we need to copy content of table renderer component into offscreen image. (e.g. showing “tooltip” which contains full lenght of rendered cell). For doing such a thing follow this code.
/** * Copy image of cell from table located in row and col. * * @param table table from which obtain the renderer * @param row row index of cell * @param col column index of cell * @returns instance of compatible Image containing copy of cell in full length. */ public Image copyImageOfCell(final JTable table, int row, int col) { final CellRendererPane cellRendererPane = new CellRenderePane(); //do not always create new cellRenderePane.. recycle usege final JComponent renderer = (JComponent) table.prepareRenderer(table.getCellRenderer(row, col), row, col); final Dimension rDim = renderer.getPreferredSize(); final Rectangle rect = table.getCellRect(row, col, true); Image image = table.getGraphicsConfiguration().createCompatibleImage(rDim.width, rDim.height); Graphics imgGraph = image.getGraphics(); imgGraph.setClip(new Rectangle(rDim)); cellRendererPane.paintComponent(imgGraph, renderer, table, 0, 0, rDim.width, rDim.height); return image; }