SimpleTextAttributes (MutableAttributeSet attr) { Object attribute = attr.getAttribute(STYLE); if (attribute == null) return null; String styleStr = attribute.toString(); Map<String, String> styles = Arrays.stream(styleStr.split("\\s*;\\s*")) .map(s -> s.split("\\s*:\\s*")) .collect(Collectors.toMap(s -> s[0], s -> s[1])); String colorString = styles.get("color"); String backgroundString = styles.get("background-color"); return new SimpleTextAttributes(parseColor(backgroundString), parseColor(colorString), null, STYLE_PLAIN); }