title: Using Font from my JAR
body: <p>I have added a font to my JAR file from eclipse and am trying to use the font within JTextFields.  The setText isn't being drawn when I run the application, just a - in the JTextField.  I based my code off <a href="https://stackoverflow.com/questions/12131584">Exporting font to jar in eclipse</a>.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>//lets load the font
  Font font = Font.createFont(Font.TRUETYPE_FONT, Main.class.getClassLoader().getResourceAsStream("Coalition_v2.ttf")); 
  font.deriveFont(Font.PLAIN, 14);
  
  txtBrain = new JTextField();
  txtBrain.setFont(font);
  txtBrain.setText("BRAIN");
  txtBrain.setHorizontalAlignment(SwingConstants.CENTER);
  txtBrain.setEditable(false);
  txtBrain.setColumns(10);
  txtBrain.setBounds(521, 727, 90, 40);
  contentPane.add(txtBrain);
  </code></pre>
  
  <p>I know the font is in the correct place as if I change the .getResourceAsStream to /Coalition_v2.ttf then I get the following error from the console:</p>
  
  <pre><code>java.io.IOException: Problem reading font data.
      at java.awt.Font.createFont(Font.java:946)
  </code></pre>
  
  <p>The Font file is contained within
  /src/</p>
  
  <p>Output of Jar -tvf as requested:</p>
  
  <pre><code> 0 Sun Mar 31 09:51:56 BST 2013 ngd/
       0 Sun Mar 31 09:51:56 BST 2013 ngd/co/
       0 Sun Mar 31 09:51:56 BST 2013 ngd/co/uk/
       0 Sun Mar 31 09:51:56 BST 2013 ngd/co/uk/TabSync/
     806 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/About$1.class
     556 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/About$2.class
    4762 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/About.class
    1802 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/Help.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$1.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$10.class
    1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$11.class
    1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$12.class
    1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$13.class
    1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$14.class
    1117 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$15.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$16.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$17.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$18.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$19.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$2.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$20.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$21.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$22.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$23.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$24.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$25.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$26.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$27.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$28.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$29.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$3.class
     735 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$30.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$31.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$32.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$33.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$34.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$35.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$36.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$37.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$38.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$39.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$4.class
    1120 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$40.class
    4765 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$41.class
     723 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$42.class
    1185 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$43.class
     697 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$44.class
    1220 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$45.class
     995 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$46.class
     781 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$47.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$5.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$6.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$7.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$8.class
     733 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$9.class
    2097 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main$Field1Listener.class
   47217 Sun Mar 31 09:52:54 BST 2013 ngd/co/uk/TabSync/Main.class
    1260 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/FileFiltererpdf.class
    1260 Sun Mar 31 08:53:20 BST 2013 ngd/co/uk/TabSync/FileFiltererjpg.class
  991552 Wed Jul 27 19:13:00 BST 2011 ngd/co/uk/TabSync/Coalition_v2.ttf
  991552 Wed Jul 27 19:13:00 BST 2011 Coalition_v2.ttf
  409717 Thu Mar 21 14:15:32 GMT 2013 nullpdf.pdf
  163009 Thu Mar 21 14:29:08 GMT 2013 Javasplash.jpg
  </code></pre>
  
  <p>The code is being run from Main.class.</p>
  
  <p>EDITED:  </p>
  
  <p>Code now looks like this:</p>
  
  <pre><code>   Font font = Font.createFont(Font.TRUETYPE_FONT, this.getClass().getResourceAsStream("/Coalition_v2.ttf")).deriveFont(Font.PLAIN, 14); 
  
  System.out.println(font)  
  </code></pre>
  
  <p>Sorted.  Thanks for your help, and Andrew for your steer in the right direction.</p>