through the above logic but when I try to select the row it is not selecting this particular column.
For example My table has 4 Columns and the image is being set in Column 4th.
Then on selecting any Row , default 3 columns are getting selected or highlighted and the 4th Column is not getting highlighted.
Are you sure it's not being selected? The visual selection is part of the renderer. DefaultTableCellRenderer renders the value with a different colour if the cell is selected; that's what the isSelected parameter indicates. If your renderer does not use a different colour if isSelected is true then the cell will be selected, just not look selected.
@Rob Spoor
Thanks for the input but is there no way to make the look identical for the entire row like SWT wizard where entire row shows highlighted blue color.
And if you want to keep your class because of the MouseListener, all you need to do is change the background colour inside the getTableCellRendererComponent method. Take a look at the source of DefaultTableCellRenderer (inside the src.zip file in your JDK root directory) for how you could do that.
I tried to change the code as suggested by you ..
So I added rendererLabel.setBackground(Color.BLUE); inside renderer getter method but I am not getting the expected.
On looking over the source code-
setBackground was the method need to be changed or I am somewhere wrong.
Please suggest.
Now everything as expected is working fine.. but I realized a thing while working on the same ..
Actually when the JTable window opens and if I click directly on the JLabel (image) based Column , then the image is gone for a while and the table returns the selected row as -1.
One more point is that the Row selection as well restricted to the previous column.
Precisely , If my Table has 4 column and Image(JLabel) is on the column number 4th, then if I directly click on the image or column 4th , then the row selection happens till the 3rd column and it returns the row selection as -1.
But If I select any other column, the everything is proper and works fine.
I am still using the same logic what I mentioned previously. What is the mistake I am committing.