It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes JTable row selection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable row selection" Watch "JTable row selection" New topic

JTable row selection

Derrick Albers

Joined: Nov 01, 2010
Posts: 20
I have a JTable that by default highlights the selected row when clicked, this works for my but I wanted to change the color of the font for a column. I created a TableCellRenderer for this and it works, the problem is that now when you select the row everything is highlight except for the cell that has a custome Renderer. How can I listen and change that cell with the row?

The is the render class:
Darryl Burke

Joined: May 03, 2008
Posts: 4523

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

edit Also note that for such trivial customization, you might as well extend DefaultTableCellRenderer.

luck, db
There are no new questions, but there may be new answers.
Derrick Albers

Joined: Nov 01, 2010
Posts: 20
I was able to fix by wrapping the value for that cell in <html> and set the font color and <u> to underline it without needing to change the Renderer.
Don't get me started about those stupid light bulbs.
subject: JTable row selection
Similar Threads
must click 2 times after clearSelection()
Problem with JTable
JTextPane as CellRenderer in JTable
JTable: Howto: Row color depending on value
column margin in JTable