Below is a hacky way, following @Piro's recommendations: using JPanel with a button as a child component. Which in itself is a good idea, given that we really don't want to touch the “internal” background images of the button.
This hacking occurs when it forces the Nimbus internals not to use the default JPanel background to fill their area, but instead to use the background of this panel instance. This requires the use of implementation details, especially a background background search engine. This happens in SynthStyle.getColor ():
// If the developer has specified a color, prefer it. Otherwise, get // the color for the state. Color color = null; if (!id.isSubregion()) { if (type == ColorType.BACKGROUND) { color = c.getBackground(); } .... } if (color == null || color instanceof UIResource) { // Then use what we've locally defined color = getColorForState(context, type); }
Translated: it does indeed request the color of the instance, but overrides it by default if the color of the instance is a UIResource, which usually occurs if used as a visualization tool. So the trick (SynthBooleanRenderer tried unsuccessfully, but this is another story ;-) should make the instance color not UIResource. Another feature is that a UIRsource is needed to ensure that the striping color, which is not a UIResource type, haha - is applied ... intuitively, isn't it?
public class RendererPanel implements TableCellRenderer { private JComponent panel; private JButton button; public RendererPanel() { panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(3, 10, 2, 10)); button = new JButton(); panel.add(button); } @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Screenshot: with unpacking hack

Screenshot: Using default colors (from the renderer installed for Object.class)

An unsafe exit may be (I have not tried it here, but remember that I did it once) to register a Region with a style, similar to what NimbusDefaults does inside:
register(Region.PANEL, "Table:\"Table.cellRenderer\"");
The problem is that there is no public api for this (or it may be that I just don't know enough about Synth;)