Java Swing Menu setMenuFont(Object item, Font theFont)

Here you can find the source of setMenuFont(Object item, Font theFont)

Description

set Menu Font

License

Open Source License

Declaration

private static void setMenuFont(Object item, Font theFont) 

Method Source Code

//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);
            }
        }
    }
}

Related

  1. makeMenubarNice()
  2. menuDigit(int digit)
  3. menuKeystroke(int virtualKey)
  4. removeMenuMnemonics(MenuElement[] elements)
  5. setFontsToMenu(MenuElement menuElement, Font font)
  6. setMenuText(AbstractButton item, String text, boolean useMnemonic)
  7. setMenuUp(boolean s, JComponent c)
  8. setViewportMenu(JComponent c)
  9. showContextMenu()