Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

public class Main {
    /**
     * Add a menu item to a JPopupMenu attaching listener to it
     * 
     * @param menu
     * @param label
     * @param listener
     */
    public static void addMenuItem(JPopupMenu menu, String label, ActionListener listener) {
        JMenuItem item = new JMenuItem(label);
        item.addActionListener(listener);
        menu.add(item);
    }
}