title: Change font size of a JPanel and all its elements
body: <p>I am trying to create a Swing panel whose elements have a different font size than the rest of the swing application. Initially, using <code>setFont</code> for a couple of components didn't pose any problems. Now I have several components (and all their subcomponents), so this solution is impractical.</p>
  
  <p>I have searched about changing the default UI properties of swing components. What I have found is mostly using the UIManager, which changes the properties globally. This doesn't work for me because I want to keep the current font settings for all the other panels.</p>
  
  <p>For the moment (and since I don't like to post without trying something out first), I have an algorithm like this:</p>
  
  <pre><code>public static void fixFont(Container c) {
      c.setFont(c.getFont().deriveFont(10.0f));
      Component[] comp = c.getComponents();
      for (int i=0;i&lt;comp.length;++i) {
          if (comp[i] instanceof Container) {
              fixFont((Container) comp[i]);
          } else {
              comp[i].setFont(comp[i].getFont().deriveFont(10.0f));
          }
      }
  }
  </code></pre>
  
  <p>The problem is that:</p>
  
  <ul>
  <li>it doesn't include certain swing elements like its border.</li>
  <li>I have to call this function when I add other components dynamically</li>
  </ul>
  
  <p><strong>Question:</strong> Is there another way to change the font properties of a Swing panel and all its components, elements, etc (i.e. everything in the panel) ?</p>
  
  <p>Thanks for your ideas</p>