0

I was reading FXExperience and I came across this. For practice I decided to make the same thing myself.

I know that you can set the shape of the button by using an SVG file. I do have an SVG file but I do not know how to work with it. The JavaFX CSS Reference says that I must pass it a String pointing to the SVG which I did but then it whines that it is invalid.

Can someone please tell me how to set the shape button using an SVG ?

An SO User
  • 23,378
  • 30
  • 119
  • 197
  • See [Load SVG file in javafx 2.0](http://stackoverflow.com/questions/6854601/load-svg-file-in-javafx-2-0) and [SVG Image in JavaFX 2.2](http://stackoverflow.com/questions/12436274/svg-image-in-javafx-2-2). – Uluk Biy Nov 15 '13 at 15:51
  • @Uluk Biy none of this is in css is it – An SO User Nov 15 '13 at 20:04
  • You said you have a svg file, so I interpreted that you want to load it. To build svg path in css file, use -fx-shape property as `-fx-shape: "M 100 100 L 300 100 L 200 300 z";`. To build svg path in code use [SVGPath](http://docs.oracle.com/javafx/2/api/javafx/scene/shape/SVGPath.html), for fxml example see [Refill a SVG Path with onMouseEntered event in JavaFX](http://stackoverflow.com/questions/15313531/refill-a-svg-path-with-onmouseentered-event-in-javafx). – Uluk Biy Nov 16 '13 at 01:31
  • @UlukBiy It is an SVG file that has a rectangle defined in it. I need to use that file as a shape for my button. ;-) – An SO User Nov 16 '13 at 02:55

0 Answers0