Two Laptop Bag
The moose likes Swing / AWT / SWT and the fly likes Help! Colors for Table Rows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help! Colors for Table Rows" Watch "Help! Colors for Table Rows" New topic

Help! Colors for Table Rows

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i was trying to set different Colors for different rows in a table, but in vain, it was easy to do this for column.
any information or piece of code that would help!
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You need to create your own DefaultTableCellRenderer. In the
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
method check the row and set the background color.
Jeff Chang

Joined: Aug 23, 2001
Posts: 23
Check out the examples at
I agree. Here's the link:
subject: Help! Colors for Table Rows
It's not a secret anymore!