Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Quetion about how to change the color of a row in a JTable

 
Mike Tilling
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How can I change the color of a row in a JTable

Best Regards
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to define a custom TableCellRenderer and apply it to all cells that make up the row.

What I did:

in my custom JTable descendent, in the setModel method and constructor:


And in the renderer, getTableCellRendererComponent method:


There's of course more code in those classes, but that's the code that is directly responsible.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Take a loo at :
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender

To make build a reder is not do hard, you only overwrite a method.

What you try to highlight with the render, the available/unavailable records ?

Regards M.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic