1
votes

I wonder whether it's possible to retrieve custom constant values set in the css file from the java code.

I went through the UIManager.themeConstants (as well as themeProps, you never know :)) but I could not find my custom constants in there.

I tried the following:

#Constants {
    --color0: #C4DFE6;
}
int color = UIManager.getInstance().getThemeConstant("--color0", 0);
                System.out.println("COLOR0=" + color);
                color = UIManager.getInstance().getThemeConstant("color0", 1);
                System.out.println("COLOR0=" + color);
                color = UIManager.getInstance().getThemeConstant("var(--color0)", 2);
                System.out.println("COLOR0=" + color);
                color = UIManager.getInstance().getThemeConstant("var(color0)", 3);
                System.out.println("COLOR0=" + color);

I was hoping one of them to return my value: 0xC4DFE6.

1

1 Answers

1
votes

The -- syntax is a special case for use within the CSS. Try using MyColor in the CSS with the same syntax in the Java side and it should work.