Following code causes unexpected result (can not apply CSS description to the property).
static StyleConverter COLOR_CONVERTER = StyleConverter.getColorConverter();
static CssMetaData<MyControl, Color> MY_COLOR =
new CssMetaData<MyControl, Color>("-my-color", COLOR_CONVERTER) { ... };
In this case, com.sun.javafx.css.parser.CSSParser generates ParsedValue<Color, Color> for a color value specified in CSS and passes it to convert method of com.sun.javafx.css.converters.ColorConverter.
However the convert method expects ParsedValue<String, Color>, so the ClassCastException thrown.
I think ColorConverter should be a StyleConverter<Object, Color>, not a StyledConverter<String, Color>.
Although the development team may already have noticed this issue, I reported just to make sure.
static StyleConverter COLOR_CONVERTER = StyleConverter.getColorConverter();
static CssMetaData<MyControl, Color> MY_COLOR =
new CssMetaData<MyControl, Color>("-my-color", COLOR_CONVERTER) { ... };
In this case, com.sun.javafx.css.parser.CSSParser generates ParsedValue<Color, Color> for a color value specified in CSS and passes it to convert method of com.sun.javafx.css.converters.ColorConverter.
However the convert method expects ParsedValue<String, Color>, so the ClassCastException thrown.
I think ColorConverter should be a StyleConverter<Object, Color>, not a StyledConverter<String, Color>.
Although the development team may already have noticed this issue, I reported just to make sure.
- duplicates
-
JDK-8093238 [CSS] com.sun.javafx.css.converters.ColorConverter seems to have a problem
- Resolved