I want to change the color of the whole row("which is containing different data types in different cells") depending upon the value of one column. Have any idea?????
Please help!!!!!!!!!!!!!!!!!!!!!!!1

Recommended Answers

All 2 Replies

a row and a column of what? a table on a jsp page? in a jTable?
what do you want and what have you tried so far? it's no use for us to try sollutions that have allready proven to you not to work.

Create your own custom TableCellRenderer, then set the background color of whatever the component is that you're returning for rendering.

Component c = whatever your component is
(rowIndex %2 == 0) ? c.setBackground(Color.blue) : c.setBackground(Color.white);

If you do this, you'll also have to control the highlighting of when the row is selected, which is easily handles in the same renderer class. The funny statement above is just an IF ELSE statement simplified. It basically says: IF row is an even number, color it blue, ELSE color white.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.