title: Change Font globally for whole frame JAVA
body: <p>im trying to change font globally for whole application, the problem is, i am able to do this only once. here is the code which helps you recreate the problem.</p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package test;
  
  import java.awt.Font;
  import java.util.Enumeration;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.SwingUtilities;
  import javax.swing.UIManager;
  
  /**
   *
   * @author osiris
   */
  public class Test {
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) throws InterruptedException {
          // TODO code application logic here
          JFrame frame = new JFrame();
          frame.setSize(600, 600);
          frame.setVisible(true);
          JButton button = new JButton("test");
          frame.add(button);
          frame.repaint();
          Thread.sleep(2000);
           Font font = new Font("Berlin Sans FB",java.awt.Font.PLAIN,14);
          Enumeration test = UIManager.getDefaults().keys();
  
          while ( test.hasMoreElements() ) {  
  
              Object key = test.nextElement();  
              Object value = UIManager.get( key );  
              if ( value instanceof Font ) {  
                  UIManager.put( key, font );  
              }  
          }
          SwingUtilities.updateComponentTreeUI(frame);
  
          Thread.sleep(2000);
           Font font2 = new Font("Tempus Sans ITC",java.awt.Font.PLAIN,14);
  
           test = UIManager.getDefaults().keys();
  
          while ( test.hasMoreElements() ) {  
  
              Object key = test.nextElement();  
              Object value = UIManager.get( key );  
              if ( value instanceof Font ) {  
                  UIManager.put( key, font2 );  
              }  
          }
          SwingUtilities.updateComponentTreeUI(frame);
      }
  }
  </code></pre>
  
  <p>The font on the button is changed only once, why is that ? why it is not changed for the second time ?</p>