How to create SVG using CSS in javaFX FXML

I use SVG for the image in the button. But I can’t fill it with color through CSS. Below is the code to create the button.

<Button  onAction="#closeApplication" >
<graphic>
 <SVGPath content="M10,16 10,0 0,8z" styleClass="button‐icon‐shape" />
</graphic>
</Button>

here is css

.button-icon-shape SVGPath{
   -fx-fill:  red;
}
+4
source share
2 answers

this is how it works. I had to style the button and use the class to style svg in the button.

<Button  onAction="#closeApplication" styleClass="closeButton">
        <graphic>
            <SVGPath content="M10,16 10,0 0,8z"  />
        </graphic>
</Button>

here is css

.closeButton{

}
.closeButton SVGPath{
   -fx-fill:  red;
}
+1
source

, , OP , . , JavaFX CSS (JFX 8) < href= "https://www.w3.org/TR/css3-selectors/#selectors" rel= "nofollow noreferrer" > .

:

<Button onAction="#closeApplication">
    <graphic>
        <SVGPath content="M10,16 10,0 0,8z" styleClass="button-icon-shape" />
    </graphic>
</Button>

JavaFX CSS :

.button-icon-shape {
   -fx-fill:red;
}
0

All Articles