How to set TableCellRenderer?

Hello everybody,Does everyone knows how to set TableCellRenderer to a JTable?If any one knows please help me...:))Thank you in advance...
[179 byte] By [vladshtr] at [2007-9-26 2:21:18]
# 1

Like this...

TableColumnModel colMdl = myTable.getColumnModel();

// get the cloumn in question

TableColumn col0 = colMdl.getColumn(0);

// set a cell renderer for all cells in this column

col0.setCellRenderer(new TwoColorCellRenderer());

You set the cell renderer for all cells in a given column. You can write your own renderer as I have w/ the TwoColorCellRenderer above, or you can use some other displayable object (JTextField, JLabel, etc...)

Hope this helps...

gil_e at 2007-6-29 9:26:16 > top of Java-index,Archived Forums,Swing...
# 2
You can set the renderers by the columns object type like this (this would be in my JTable object):setDefaultRenderer(Integer.class, new ColorRenderer());setDefaultRenderer(Object.class, new ColorRenderer());setDefaultRenderer(Boolean.class, new BooleanRenderer());
mmbc at 2007-6-29 9:26:16 > top of Java-index,Archived Forums,Swing...