Example usage for javax.swing JMenu removeMenuListener

List of usage examples for javax.swing JMenu removeMenuListener

Introduction

In this page you can find the example usage for javax.swing JMenu removeMenuListener.

Prototype

public void removeMenuListener(MenuListener l) 

Source Link

Document

Removes a listener for menu events.

Usage

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("MenuSample Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar menuBar = new JMenuBar();

    // File Menu, F - Mnemonic
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);/*from   ww  w.j  a  va2  s  .  co m*/

    MenuListener lis = new MenuListener() {

        public void menuSelected(MenuEvent e) {
            System.out.println("menuSelected");
        }

        public void menuDeselected(MenuEvent e) {
            System.out.println("menuDeselected");

        }

        public void menuCanceled(MenuEvent e) {
            System.out.println("menuCanceled");

        }
    };

    fileMenu.addMenuListener(lis);

    // File->New, N - Mnemonic
    JMenuItem newMenuItem = new JMenuItem("New");
    fileMenu.add(newMenuItem);

    frame.setJMenuBar(menuBar);
    frame.setSize(350, 250);
    frame.setVisible(true);

    fileMenu.removeMenuListener(lis);
}