• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help! Colors for Table Rows

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hi
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!
Thanx
-----
Imed
 
Paul Stevens
Ranch Hand
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the examples at
http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic