Delegating to the original renderer basically is the right direction to go, just slightly differently:
- use a compoundBorder of the original and the emptyBorder
- nudge the original renderer to re-set the border to its original by making the padded border a UIResource
Something like:
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
JComponent comp = (JComponent) originalRenderer.getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
Border originalBorder = comp.getBorder();
comp.setBorder(new CompoundBorderUIResource(originalBorder,
BorderFactory.createEmptyBorder(0, 20, 0, 0)));
return comp;
}
It's brittle, though, as LAFs might ignore your setting: the trick works fine for WinLAF, but not at all for Nimbus - so don't know the outcome on Mac.