Here you can find the source of setMenuFont(Object item, Font theFont)
private static void setMenuFont(Object item, Font theFont)
//package com.java2s; /**//w w w . jav a 2 s. co m * Software License * * Copyright 2007/2010 National Library of New Zealand. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * or the file "LICENSE.txt" included with the software. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. * */ import java.awt.Font; import javax.swing.JMenu; import javax.swing.JMenuItem; public class Main { private static void setMenuFont(Object item, Font theFont) { if (item instanceof JMenu) { JMenu menu = (JMenu) item; menu.setFont(theFont); for (int j = 0; j < menu.getItemCount(); j++) { if (menu.getItem(j) != null) { setMenuFont(menu.getItem(j), theFont); } } } else { JMenuItem menuItem = (JMenuItem) item; menuItem.setFont(theFont); for (int i = 0; i < menuItem.getSubElements().length; i++) { setMenuFont((JMenuItem) menuItem.getSubElements()[i], theFont); } } } }