I have a custom cell render for a JTable.
I create for each cell a JPanel that contains a JLabel and a JButton.
Question is, How can I get the actual rendered component object (the
JPanel) of a cell for a given row and column index.
Thanks for help.
I'm not sure what you're asking. I take it your renderer extends JPanel
and implements TableCellRenderer. Perhaps you can show an example that
illustrates what your trying to do.
The JTable method getCellRenderer(row, col) will return the default
renderer based on the type specified by your table's data model, using
getColumnClass(). After you set your custom renderer, getCellRenderer
will return a reference to your custom renderer.
There's more detail here:
<http://java.sun.com/docs/books/tutorial/uiswing/components/table.html>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
JPanel p = (JPanel)table.dataModel().getValueAt(row, column);
--
Fred K
The correct answer is that the Component used to render a cell is often
only transient. Even if your getCellRendererComponent method returns a
new instance every time, it is thrown away after it is used to render.
If it returns the *same* instance every time (as is a common idiom),
then it is re-used, but not held on to.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
>
>Question is, How can I get the actual rendered component object (the
>JPanel) of a cell for a given row and column index.
It does not exist. The same component is recycled to render each
cell.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The USA and Iraq are as mismatched combatants as Mike Tyson and a bag lady. Americans make themselves look ridiculous when they justify invading and occupying Iraq in self defence.