2

I am working on JavaFX GUI. I wanted to use Font Awesome icons. I found really cool lib FontAwesomeFX » 8.9 which allows to use icons in fxml code like this:

                 <FontAwesomeIcon fill="red" glyphName="NAME" />

Does anyone know how to attach it to the button using only fxml, so I can style it using css?

  • 1
    Attach it to a button??? Does that mean you want to use it instead of the button's text? Also how exactly this related to css styling? Also "attaching" a icon to a button hardly seems to be a prequesite for css to apply to the icon. Could you clarify this? – fabian Jan 06 '18 at 22:52
  • https://stackoverflow.com/questions/24430121/how-to-use-font-awesome-in-a-fxml-project-javafx – SedJ601 Jan 06 '18 at 23:22
  • Yes, I would like to have a button with a text label and an icon inside. Font Awsome icons are vector graphics and can be customized with css (e.g. size, color, drop shadow etc.) – Krzysztof Skolimowski Jan 07 '18 at 00:01
  • If you use `SceneBuilder` is a matter of drag and drop. – SedJ601 Jan 07 '18 at 05:05

1 Answers1

2
 <JFXButton fx:id="delete_btn" text="Supprimer le client">
     <graphic>
         <FontAwesomeIconView fill="WHITE" glyphName="TRASH_ALT" size="16.0"/>
     </graphic>
 </JFXButton>

I use an other library (JFoenix) but it's the same thing with JButton

JustinMartinDev
  • 559
  • 2
  • 7
  • 23