title: Text with Icon on MenuItem JavaFx
body: <p>I am working on a project using JavaFX. I have included FontAwesome in my project to avoid using images for simple icons. I created the following function in a constants class that generates an HBox with an icon and text that will be called in the <code>setGraphic(Node node)</code>. The function is as follows:</p>
  
  <pre><code>public static HBox iconText(String icon, String text) {
      return ConstantsClass.iconText(icon, text, 5);
  }
  
  public static HBox iconText(String icon, String text, int spacing) {
      HBox box = new HBox(spacing);
      Label iconLabel = new Label(icon);
      iconLabel.setFont(ConstantsClass.fontAwesome);
      Label textLabel = new Label(text);
      box.getChildren().addAll(iconLabel, textLabel);
      return box;
  }
  </code></pre>
  
  <p>The method works perfectly on buttons, such as having a back button with an arrow icon. However it does not seem to work on MenuItems.</p>
  
  <p>I have a menu bar at the top of my application with Menus in them, and MenuItems in those. I tried the same process with a "settings" MenuItem, but the text does not appear unless the cursor is over the item.</p>
  
  <pre><code>MenuItem settings = new MenuItem();
  settings.setGraphic(ConstantsClass.iconText(FontAwesome.COG, "Settings")); //Obscuring name of Constants Class
  </code></pre>
  
  <p>This code has the following results:</p>
  
  <p><a href="https://i.stack.imgur.com/6AkRJ.png" rel="nofollow noreferrer">When the user just clicks on the menu drop down</a></p>
  
  <p><a href="https://i.stack.imgur.com/d6ty0.png" rel="nofollow noreferrer">When the user hovers over the Menu Item</a></p>
  
  <p>How can I make the MenuItem always show the icon and text?</p>