title: Using a custom font for a JLabel
body: <p>I'm trying to use a special font in my JFrame, but I'm running into problems. I have a JLabel defined like this:</p>
  
  <pre><code>private JLabel lab = new JLabel("Text");
  </code></pre>
  
  <p>and I have a file called CUSTOMFONT-MEDIUM.TTF (TrueType font) but after writing the following:</p>
  
  <pre><code>    try {
      lab.setFont(Font.createFont(Font.TRUETYPE_FONT, getClass().getResource("/CUSTOMFONT-MEDIUM.TTF").openStream()));
      } catch(IOException ex){
      //exception handled here I suppose  
      } catch(FontFormatException ex2) {
      //same here
      }
  </code></pre>
  
  <p>the code compiles and the everything works right except that "lab" is not displayed so there is no text. I suppose it is because I never specified what the font size should be, but any attempt I have made to do that fails. Can someone help me out here?</p>