G5 Toolbar default background color is gray

Software version:

  • Polyscope 3.6 and 3.8
  • URCap SDK 1.3.0

Robot generation: G5

Steps to reproduce:

  1. Register a SwingToolbarService
  2. 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.

I am not able to reproduce this behavior.
With a Toolbar-only URCap on PolyScope 5.2 I add:
image

And from the terminal I find that:
image

Hence an all-white background on the provided JPanel.

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.