Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To set color for rows in JTable

 
Rajan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Can any body help me in setting different color for rows. I have done it for column.
thanks
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rajan",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the DefaultCellRenderer this method
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Gives both the row and column. Check the row and do what you would have for the column.
 
Rajan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
I have to do it dynamically. How can i pass the row index so that i can check with the getTableCellRendererComponent method's row(int).
Once after creating the table, according to certain creteria i have change the color of the corresponding row.
Can help me in this issue.
thanks
Rajan

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic