I wanna add a button to some specific cells where i might get null characters from my database. I tried overriding 'TableCellRenderer' . But it keep adding buttons to entire column. What should i do? (example wd b better)
But it keep adding buttons to entire column.
Yes, a renderer is designed to work for the entire column.
If you want a different renderer for a different row then you can override the getCellRenderer(...)
method. Something like:
public TableCellEditor getCellEditor(int row, int column)
{
Object value = getValueAt(row, column);
if (value == null)
{
return super.getCellEditor(row, column);
}
else
return getDefaultRenderer(value.getClass());
}
You would also need similar code for the getCellEditor(...)
method.
You can also check out Table Button Column for an example of a button renderer/editor.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.