This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
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.
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.
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.
subject: Table Row Selection problem while adding any Image in a JTable