Here you can find the source of getMenuItems(JMenu menu)
public static JMenuItem[] getMenuItems(JMenu menu)
//package com.java2s; /*//from www.ja v a2s. c om * Copyright 2001-2008 Aqris Software AS. All rights reserved. * * This program is dual-licensed under both the Common Development * and Distribution License ("CDDL") and the GNU General Public * License ("GPL"). You may elect to use one or the other of these * licenses. */ import javax.swing.JMenu; import javax.swing.JMenuItem; public class Main { public static JMenuItem[] getMenuItems(JMenu menu) { JMenuItem[] result = new JMenuItem[menu.getItemCount()]; for (int i = 0; i < result.length; i++) { result[i] = menu.getItem(i); } return result; } }