Java JMenu countCheckBoxMenuItem(JMenu menu)

Here you can find the source of countCheckBoxMenuItem(JMenu menu)

Description

count Check Box Menu Item

License

Open Source License

Declaration

public final static int countCheckBoxMenuItem(JMenu menu) 

Method Source Code


//package com.java2s;
/*//w  w  w  .  j  ava 2s  .c o  m
 *  Copyright 2007, Plutext Pty Ltd.
 *   
 *  This file is part of Docx4all.
    
Docx4all is free software: you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License 
as published by the Free Software Foundation.
    
Docx4all is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License   
along with Docx4all.  If not, see <http://www.gnu.org/licenses/>.
    
 */

import java.awt.Component;

import javax.swing.JCheckBoxMenuItem;

import javax.swing.JMenu;

public class Main {
    public final static int countCheckBoxMenuItem(JMenu menu) {
        int count = 0;
        for (int i = 0; i < menu.getMenuComponentCount(); i++) {
            Component c = menu.getMenuComponent(i);
            if (c instanceof JCheckBoxMenuItem) {
                count++;
            }
        }
        return count;
    }
}

Related

  1. applyDefaultProperties(final JMenu comp)
  2. assignMnemonics(JMenu menu)
  3. changeMenuItemsState(final JMenu menu, final boolean enableState)
  4. constructRecentlyFilesMenuItems(JMenu recentlyOpenFilesMenuItem, LinkedHashMap filesOpenedLHM)
  5. containsMenuComponent(JMenu parent, Component comp)
  6. createMenu(String menuText, JMenu menu, ActionListener listener)
  7. createMenuBar(JMenu... menues)
  8. createMenuItem(JMenu parent, String text)
  9. createMenuItemCustomAction(JMenu menu, int type, String text, String command, ImageIcon image, int acceleratorKey, String toolTip, ActionListener action)