Add font awesome to menu item javafx

LinkedIn Tweet Facebook
Add font awesome to menu item javafx

Maven dependency to add font awesome to your project


We will require the GlyphsDude class for setting the icon. Since FontAwesomeIcon object cannot be directly used in MenuItem constructor.

import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;

MenuItem downloadMenuItem;
downloadMenuItem = new MenuItem("Download");
GlyphsDude.setIcon(downloadMenuItem, FontAwesomeIcon.DOWNLOAD);
ContextMenu menu = new ContextMenu();