title: Add icons to JButton using custom font from AwesomeFont and unicode characters in Java Swing?
body: <p>I have a JButton and I want to add an icon to it. I would like to use the font based icons from FontAwesome which provides a TrueType font file. The icon I am trying to add is the play button icon. The play button icon in the css file for FontAwesome is <code>\f04b</code> which I beleive translates to <code>\uf04b</code> in Java.</p>
  
  <p>This is how I am loading the font in the constructor of by IconButton base class. </p>
  
  <pre><code>public class IconButton extends JButton {
    public IconButton() {
      try {
        InputStream in = this.getClass().getResourceAsStream("/fontawesome-webfont.ttf");
        Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, in);
        Font ttfReal = ttfBase.deriveFont(Font.BOLD, 24);
        setFont(ttfReal);
      } catch (FontFormatException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
    }
  }
  </code></pre>
  
  <p>In the implementing class StartButton this is how I am setting the text.</p>
  
  <pre><code>public class StartButton extends IconButton {
    public StartButton() {
      setText(String.valueOf('\u0f4b'));
      setForeground(Color.BLACK);
    }
  }
  </code></pre>
  
  <p>This is what I get. Nothing.</p>
  
  <p><img src="https://i.stack.imgur.com/dIZOm.png" alt="JButton"></p>
  
  <p>Any help is much appreciated.</p>
  
  <p>EDIT: See answer below.</p>