Java examples for org.w3c.dom.css:CSSStyleDeclaration
update CSS Decoration
//package com.java2s; import javax.swing.ButtonModel; import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.CSSValue; import org.w3c.dom.css.ElementCSSInlineStyle; public class Main { public static void updateDecoration(ButtonModel model, ElementCSSInlineStyle elemStyle) { if (model.isSelected()) { selectDecoration(elemStyle); } else {//from ww w .j a v a2s. co m unselectDecoration(elemStyle); } } public static void selectDecoration(ElementCSSInlineStyle elemStyle) { CSSStyleDeclaration style = elemStyle.getStyle(); CSSValue cssValue = style.getPropertyCSSValue("color"); // Usar el CSSValue es la forma m?s lenta pero es para testear if (cssValue == null) style.setProperty("color", "red", ""); else cssValue.setCssText("red"); } public static void unselectDecoration(ElementCSSInlineStyle elemStyle) { CSSStyleDeclaration style = elemStyle.getStyle(); style.removeProperty("color"); } }