title: Swing - Change menu bar and menu items font size in runtime
body: <p>as title says, I need to change the font size of the menu bar and every item on it (and also the items of the ite,s) using SWING.</p>
  
  <p>I have the following code which works but not on runtime, I need it to be when clicking on a menu item</p>
  
  <pre><code>Font f = new Font("sans-serif", Font.PLAIN, 12);
  UIManager.put("Menu.font", f);
  UIManager.put("MenuItem.font", f);
  </code></pre>
  
  <p>And the code I have for my menu is</p>
  
  <pre><code>private class foo{
          private JMenu mnArchivo;
          private JMenuBar menuBar;
          menuBar = new JMenuBar();
          frmAdministracinHospital.setJMenuBar(menuBar);
  
      JRadioButtonMenuItem rdbtnmntmGrande = new JRadioButtonMenuItem("Grande");
              rdbtnmntmGrande.addActionListener(new MiGrandeActionListener());
              rdbtnmntmGrande.setIcon(new ImageIcon(PrincipalWindow.class.getResource("/presentacion/fontbig.png")));
              buttonGroup.add(rdbtnmntmGrande);
              mnTamanoFuente.add(rdbtnmntmGrande);
  
      private class MiGrandeActionListener implements ActionListener {
              public void actionPerformed(ActionEvent e) {
  
                  Font f = new Font(menuBar.getFont().getFontName(), menuBar.getFont().getStyle(), 12);
                  UIManager.put("Menu.font", f);
              }
          }
  </code></pre>
  
  <p>I haven't found any similar question which does it on run time, how could I achieve this?</p>
  
  <p><strong>EDIT. CODE ADD WITH NO WORKING THE FONT SIZE CHANGE MORE THAN ONCE.</strong></p>
  
  <pre><code>package presentacion;
  
  import java.awt.EventQueue;
  import java.awt.Font;
  import java.awt.SystemColor;
  import java.awt.Toolkit;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.ButtonGroup;
  import javax.swing.ImageIcon;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JPanel;
  import javax.swing.JRadioButtonMenuItem;
  import javax.swing.JTabbedPane;
  import javax.swing.JTextField;
  import javax.swing.SwingUtilities;
  import javax.swing.UIManager;
  import javax.swing.UnsupportedLookAndFeelException;
  
  import dominio.Appointment;
  import dominio.Patient;
  import dominio.Specialist;
  
  
  public class pepe {
  
      private JFrame a;
      private JTabbedPane tabbedPane;
      private JMenuBar menuBar;
      private final ButtonGroup buttonGroup = new ButtonGroup();
  
  
      public pepe() {
          initialize();
          a.setVisible(true);
      }
  
      public static void main(String[] args) {
  
          try {
              // Set System L&amp;F
          UIManager.setLookAndFeel(
              UIManager.getSystemLookAndFeelClassName());
      } 
      catch (UnsupportedLookAndFeelException e) {
         // handle exception
      }
      catch (ClassNotFoundException e) {
         // handle exception
      }
      catch (InstantiationException e) {
         // handle exception
      }
      catch (IllegalAccessException e) {
         // handle exception
      }
  
          EventQueue.invokeLater(new Runnable() {
              public void run() {
                  try {
                      pepe window = new pepe();
                      window.a.setVisible(true);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          });
      }
  
      private void initialize() {
          a = new JFrame();
          a.setTitle("Administraci\u00F3n Hospital");
          a.setBounds(100, 100, 1195, 710);
          a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          tabbedPane = new JTabbedPane(JTabbedPane.TOP);
          tabbedPane.setBackground(SystemColor.info);
  
          menuBar = new JMenuBar();
          a.setJMenuBar(menuBar);
  
          JMenu mnVer = new JMenu("Ver");
          menuBar.add(mnVer);
  
          JMenu mnTamanoFuente = new JMenu("Tama\u00F1o fuente");
          mnVer.add(mnTamanoFuente);
  
          JRadioButtonMenuItem rdbtnmntmPequeo = new JRadioButtonMenuItem("Peque\u00F1o");
          rdbtnmntmPequeo.addActionListener(new MiPequenaActionListener());
          buttonGroup.add(rdbtnmntmPequeo);
          mnTamanoFuente.add(rdbtnmntmPequeo);
  
          JRadioButtonMenuItem rdbtnmntmGrande = new JRadioButtonMenuItem("Grande");
          rdbtnmntmGrande.addActionListener(new MiGrandeActionListener());
          buttonGroup.add(rdbtnmntmGrande);
          mnTamanoFuente.add(rdbtnmntmGrande);
  
      }
  
      private class MiPequenaActionListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
              Font f = new Font(a.getFont().getFontName(), a.getFont().getStyle(), 10);
              UIManager.put("Label.font", f);
              UIManager.put("Menu.font", f);
              UIManager.put("MenuItem.font", f);
              SwingUtilities.updateComponentTreeUI(a);
  
          }
      }
  
      private class MiGrandeActionListener implements ActionListener {
          public void actionPerformed(ActionEvent e) {
              Font f = new Font(a.getFont().getFontName(), a.getFont().getStyle(), 13);
              UIManager.put("Label.font", f);
              UIManager.put("Menu.font", f);
              UIManager.put("MenuItem.font", f);
              SwingUtilities.updateComponentTreeUI(a);
          }
      }
  
  }
  </code></pre>
  
  <p>With this it lets me change the font size just once, to big for example (grande) if then I click on small or normal it wont do anything.</p>
  
  <p>Thank you.</p>