3

In my Java application I have to custom-paint a control and for that I need to use the same font colors as JButton. (Enabled and disabled) I don't want to hard-code them, because the user can change the Substance skin at runtime.

I'm aware of the ColorSchemes but I'm not sure how to proceed once I have the color scheme of the current skin. Also the Substance documentation says something about creating your own color scheme, but I just can't figure out the way to retrieve a certain color.

Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329

2 Answers2

2

OK, finally I figured it out myself:

The important step is to figure out the correct color scheme. Because in Substance every root pane can have its own skin, it's best to use the getCurrentSkinhelper.

SubstanceColorScheme s = SubstanceLookAndFeel
        .getCurrentSkin(myComponent)
        .getEnabledColorScheme(
                SubstanceLookAndFeel.getDecorationType(myComponent)
         );

Other possibilities are getDisabledColorScheme, getActiveColorScheme and getBackgroundColorScheme.

Then you can use s.getForegroundColor or various helper methods from SubstanceColorUtilities.

Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329
0

Why don't you ask Kirill (creator of Substance) on Substance Forum at https://substance.dev.java.net/servlets/ProjectForumView

Eugene Ryzhikov
  • 17,131
  • 3
  • 38
  • 60