File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
Don't get me started about those stupid light bulbs.
subject: Help! Colors for Table Rows
Similar Threads
Datatable rows onMouseOut color change
Alternate colors to table rows
How to apply CSS to JSF Datatable
xml data islands + alternate row color
alternate rows in one color