Java JMenu addListenerToItems(JMenu menu, ActionListener listener)

Here you can find the source of addListenerToItems(JMenu menu, ActionListener listener)

Description

add Listener To Items

License

Open Source License

Declaration

public static void addListenerToItems(JMenu menu, ActionListener listener) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

public class Main {
    public static void addListenerToItems(JMenu menu, ActionListener listener) {
        for (int i = 0; i < menu.getItemCount(); i++) {
            JMenuItem jmi = menu.getItem(i);
            if (jmi != null)
                jmi.addActionListener(listener);
        }/*from   ww w.  j ava2s. co  m*/
    }
}

Related

  1. addMenuItem(ActionListener al, JMenu m, String label, String command, int key, int ckey)
  2. addMenuItem(ActionListener li, JMenu menu, String text, String tip)
  3. addMenuItem(JMenu menu, Action action)
  4. addMenuItem(JMenu menu, String label, Action action, int mnemonic, String tooltip, boolean isEnabled)