Here you can find the source of exit(JMenuItem anItem)
public static void exit(JMenuItem anItem)
//package com.java2s; //License from project: Open Source License import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JMenuItem; public class Main { public static void exit(JButton aButton) { aButton.addActionListener(new ActionListener() { @Override//from w w w . j a v a 2 s. c o m public void actionPerformed(ActionEvent event) { System.exit(0); } }); } public static void exit(JMenuItem anItem) { anItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.exit(0); } }); } }