I want to display an icon in a specific JTable
cell, and not have the same icon in the whole column's cells.
Asked
Active
Viewed 1,287 times
0
-
1Please edit your question to include an [sscce](http://sscce.org/) that shows what you've tried, for [example](http://stackoverflow.com/q/14470230/230513). – trashgod Aug 27 '13 at 00:19
1 Answers
1
Assuming you've done your research and know how to use custom cell renderers, the basic concept is simple.
public Component getTableCellRendererComponent(
JTable table, Object color,
boolean isSelected, boolean hasFocus,
int row, int column) {
// Prepare renderer as usual...
// Check to see if the current row/column is within
// the acceptable range...
// It would be usful if this information was coming from
// some kind of model
if (row == iconRow && column == iconColumn) {
// Apply the icon for this cell renderer
}
return this;
}

MadProgrammer
- 343,457
- 22
- 230
- 366