Class StyleConverter<F,T>
- javafx.css.StyleConverter<F,T>
Direct Known Subclasses:
com.sun.javafx.css.StyleConverterImpl
public class StyleConverter<F,T> extends Object
ParsedValue&tl;F,T> from type F to type T. the CssMetaData API requires a StyleConverter which is used when computing a value for the StyleableProperty. There are a number of predefined converters which are accessible by the static methods of this class.Since:
JavaFX 8.0
See Also:
-
Constructor Summary
Constructors Constructor and Description StyleConverter()
-
Method Summary
-
Constructor Detail
-
StyleConverter
public StyleConverter()
-
-
Method Detail
-
convert
public T convert(ParsedValue<F,T> value, Font font)Convert from the parsed CSS value to the target property type.Parameters:
value- TheParsedValueto convert
-
getBooleanConverter
public static StyleConverter<String,Boolean> getBooleanConverter()
Returns:
A
StyleConverterthat converts "true" or "false" toBooleanSee Also:
-
getDurationConverter
public static StyleConverter<?,Duration> getDurationConverter()
Returns:
A
StyleConverterthat converts a String representation of a duration to aDurationSince:
JavaFX 8u40
-
getColorConverter
public static StyleConverter<String,Color> getColorConverter()
Returns:
A
StyleConverterthat converts a String representation of a web color to aColorSee Also:
-
getEffectConverter
public static StyleConverter<ParsedValue[],Effect> getEffectConverter()
Returns:
A
StyleConverterthat converts a parsed representation of anEffectto anEffectSee Also:
-
getEnumConverter
public static <E extends Enum<E>> StyleConverter<String,? extends Enum<?>> getEnumConverter(Class<E> enumClass)
Returns:
A
StyleConverterthat converts a String representation of anEnumto anEnum
-
getFontConverter
public static StyleConverter<ParsedValue[],Font> getFontConverter()
Returns:
A
StyleConverterthat converts a parsed representation of aFontto anFont.
-
getInsetsConverter
public static StyleConverter<ParsedValue[],Insets> getInsetsConverter()
Returns:
A
StyleConverterthat converts a [<length> | <percentage>]{1,4} to anInsets.
-
getPaintConverter
public static StyleConverter<ParsedValue<?,Paint>,Paint> getPaintConverter()
Returns:
A
StyleConverterthat converts a parsed representation of aPaintto aPaint.
-
getSizeConverter
public static StyleConverter<?,Number> getSizeConverter()
CSS length and number values are parsed into a Size object that is converted to a Number before the value is applied. If the property is aNumbertype other than Double, thesetmethod of (CssMetaDatacan be over-ridden to convert the Number to the correct type. For example, if the property is anIntegerProperty:@Override public void set(MyNode node, Number value, Origin origin) { if (value != null) { super.set(node, value.intValue(), origin); } else { super.set(node, value, origin); } }Returns:
A
StyleConverterthat converts a parsed representation of a CSS length or number value to aNumberthat is an instance ofDouble.
-
getStringConverter
public static StyleConverter<String,String> getStringConverter()
A converter for quoted strings which may have embedded unicode characters.Returns:
A
StyleConverterthat converts a representation of a CSS string value to aString.
-
getUrlConverter
public static StyleConverter<ParsedValue[],String> getUrlConverter()
A converter for URL strings.Returns:
A
StyleConverterthat converts a representation of a CSS URL value to aString.
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.