Uploaded September 2018 | Updated November 2026, 1 day ago
JavaFX provides option to define custom shapes using SVG paths. So, any shape as per your preference can be applied to almost all the controls (or the controls that extends Region class) in JavaFX User Interface library.
Read more from: genuinecoder.com/custom-shapes-for-javafx-ui-components
In this example, I have used JFXTextField text field from JFoenix library for getting material design based buttons.
I have used Scene builder for preparing this tutorial.
Basics of SVG Path: w3schools.com/graphics/svg_path.asp
Create your own shapes from codepen.io/anthonydugois/pen/mewdyZ
JavaFX Region: docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/Region.html
SVG Path Syntax: w3.org/TR/SVG/paths.html
SVG Path for Heart Symbol:-
---------1------------
-fx-shape: "M23.6,0c-3.4,0-6.3,2.7-7.6,5.6C14.7,2.7,11.8,0,8.4,0C3.8,0,0,3.8,0,8.4c0,9.4,9.5,11.9,16,21.2
c6.1-9.3,16-12.1,16-21.2C32,3.8,28.2,0,23.6,0z";
---------2-------------
-fx-shape: "M340.8,98.4c50.7,0,91.9,41.3,91.9,92.3c0,26.2-10.9,49.8-28.3,66.6L256,407.1L105,254.6c-15.8-16.6-25.6-39.1-25.6-63.9
c0-51,41.1-92.3,91.9-92.3c38.2,0,70.9,23.4,84.8,56.8C269.8,121.9,302.6,98.4,340.8,98.4 M340.8,83C307,83,276,98.8,256,124.8
c-20-26-51-41.8-84.8-41.8C112.1,83,64,131.3,64,190.7c0,27.9,10.6,54.4,29.9,74.6L245.1,418l10.9,11l10.9-11l148.3-149.8
c21-20.3,32.8-47.9,32.8-77.5C448,131.3,399.9,83,340.8,83L340.8,83z";
Code is available in GitHub: github.com/afsalashyana/JavaFX-Tutorial-Codes/tree/master/JavaFX%20Custom%20Shape%20Buttons
Read more about custom shaped components at genuinecoder.com/javafx-buttons-with-custom-shape
JavaFX provides option to define custom shapes using SVG paths. So, any shape as per your preference can be applied to almost all the controls (or the controls that extends Region class) in JavaFX User Interface library.
Read more from: genuinecoder.com/custom-shapes-for-javafx-ui-components
In this example, I have used JFXTextField text field from JFoenix library for getting material design based buttons.
I have used Scene builder for preparing this tutorial.
Basics of SVG Path: w3schools.com/graphics/svg_path.asp
Create your own shapes from codepen.io/anthonydugois/pen/mewdyZ
JavaFX Region: docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/Region.html
SVG Path Syntax: w3.org/TR/SVG/paths.html
SVG Path for Heart Symbol:-
---------1------------
-fx-shape: "M23.6,0c-3.4,0-6.3,2.7-7.6,5.6C14.7,2.7,11.8,0,8.4,0C3.8,0,0,3.8,0,8.4c0,9.4,9.5,11.9,16,21.2
c6.1-9.3,16-12.1,16-21.2C32,3.8,28.2,0,23.6,0z";
---------2-------------
-fx-shape: "M340.8,98.4c50.7,0,91.9,41.3,91.9,92.3c0,26.2-10.9,49.8-28.3,66.6L256,407.1L105,254.6c-15.8-16.6-25.6-39.1-25.6-63.9
c0-51,41.1-92.3,91.9-92.3c38.2,0,70.9,23.4,84.8,56.8C269.8,121.9,302.6,98.4,340.8,98.4 M340.8,83C307,83,276,98.8,256,124.8
c-20-26-51-41.8-84.8-41.8C112.1,83,64,131.3,64,190.7c0,27.9,10.6,54.4,29.9,74.6L245.1,418l10.9,11l10.9-11l148.3-149.8
c21-20.3,32.8-47.9,32.8-77.5C448,131.3,399.9,83,340.8,83L340.8,83z";
Code is available in GitHub: github.com/afsalashyana/JavaFX-Tutorial-Codes/tree/master/JavaFX%20Custom%20Shape%20Buttons
Read more about custom shaped components at genuinecoder.com/javafx-buttons-with-custom-shape










