Swing components delegate their look and feel to ComponentUI
objects. As part of Swing, there are interfaces defined for each component: ButtonUI
which JButton
delegates to, LabelUI
for JLabel
, TextUI
for JTextPane
, etc.
Each Swing look and feel contains implementations for each of those interfaces. eg. MetalButtonUI
, MetalLabelUI
, etc. which paint that component however the look and feel wants to.
When you call UIManager.setLookAndFeel
it swaps in that set of implementations.
All very clever, but the annoying thing is that each look and feel doesn't have to honour any of your foreground / background / border, etc. settings.
Luckily, Nimbus defines all of its colours as UIManager keys.
So, you can do this sort of thing to override its default colours:
UIManager.put("nimbusBase", Color.BLACK);
See here for full list:
Update
Although, saying that, it doesn't look like Nimbus plays nicely at all! Some people have had some luck overriding Nimbus colours with this:
Color bgColor = new Color("99999");
UIDefaults defaults = new UIDefaults();
defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
jeditorpane.putClientProperty("Nimbus.Overrides", defaults);
jeditorpane.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
jeditorpane.setBackground(bgColor);