aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Quetion about how to change the color of a row in a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Quetion about how to change the color of a row in a JTable" Watch "Quetion about how to change the color of a row in a JTable" New topic
Author

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

Mike Tilling
Ranch Hand

Joined: Feb 17, 2006
Posts: 86
Hi

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

Best Regards
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
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.


42
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

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.


SCJP, SCJD, SCWCD, OCPJBCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Quetion about how to change the color of a row in a JTable