943,912 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2057
  • Java RSS
Feb 27th, 2008
0

How to change color of a row

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
chankya is offline Offline
6 posts
since Jan 2008
Feb 27th, 2008
0

Re: How to change color of a row

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.
Reputation Points: 935
Solved Threads: 356
Nearly a Posting Maven
stultuske is offline Offline
2,497 posts
since Jan 2007
Feb 27th, 2008
1

Re: How to change color of a row

Create your own custom TableCellRenderer, then set the background color of whatever the component is that you're returning for rendering.
Java Syntax (Toggle Plain Text)
  1. Component c = whatever your component is
  2. (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.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: ClassNotFoundException with MySql and Netbeans
Next Thread in Java Forum Timeline: problem in game





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC