In the implementation of SwingToolbarContribution, add components to the JPanel in buildUI method.
Expected behavior:
Background of all components should be white.
Actual behavior:
Background of components is gray.
Observation:
By debugging this, I’ve found that PolyScope seems to set its default background color (white for G5) in UIManager after the toolbar service is initialized and after the toolbar view is created (in buildUI method). Therefore, when the toolbar view is created, its background color is gray because it use the default background color set in UIManager at this moment.
Workaround:
Set white background to all components of the JPanel in buildUI method.
My apologies, after more investigation, the problem is not in the buildUI method. The problem is the SwingToolbarContribution constructor which is called before default colors/UI are set in the UIManager. You can check that value with UIManager.get(“Panel.Background”).
I was creating my toolbar view (which I add to the JPanel in buildUI afterwards) in SwingToolbarContribution constructor which at that time, the default color (white) is not set yet.
It’s still an inconsistent behavior since all the other contribution classes are created after colors/UI are set in the UIManager.