How to change a color of a single row in a JTable
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   nava_Pppp
Posted On:   Thursday, April 5, 2001 07:14 PM

I'm trying to change the color of a row in a JTable. I tried: Component comp=(DefaultTableCellRenderer) (trapListTable.getCellRenderer(0, 0)); comp.setForeground(Color.red); but it colored the whole table. I also tried: DefaultCellEditor tc=(DefaultCellEditor)(trapListTable.getCellEditor(1,1)); Component comp1=tc.getComponent(); comp1.setForeground(Color.red); but it didn't colored any row Thanks Nava Polak Onik navap@radware.com Radware Israel Does anyone has idea how to do it?    More>>

I'm trying to change the color of a row in a JTable. I tried:
Component comp=(DefaultTableCellRenderer)

(trapListTable.getCellRenderer(0, 0));
comp.setForeground(Color.red);

but it colored the whole table.

I also tried:
DefaultCellEditor tc=(DefaultCellEditor)(trapListTable.getCellEditor(1,1));

Component comp1=tc.getComponent();

comp1.setForeground(Color.red);

but it didn't colored any row

Thanks
Nava Polak Onik
navap@radware.com
Radware Israel

Does anyone has idea how to do it?

   <<Less

Re: How to change a color of a single row in a JTable

Posted By:   Sandip_Chitale  
Posted On:   Monday, April 9, 2001 12:55 PM

It is a matter of installing the right
TableCellRenderer. Please llok at the
JavaDoc for it. Basically when the
row number matches the row of your interest set a diffrent foreground and
background color on the returned TableCellRenderer component.
About | Sitemap | Contact