How can I prevent cell highlighting in a JTable?

Scott Stanchfield

The easiest way to accomplish this is to use a custom cell renderer that doesn't paint a background.

Search the Swing FAQ for "TableCellRenderer"; there are many FAQs about how to create one. If you create a table cell renderer that uses a label (or subclasses DefaultTableCellRenderer), all you need to do is call

setOpaque(false);

in your getTableCellRendererComponent() method.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact