Here you can find the source of exit(JButton aButton)
public static void exit(JButton aButton)
//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 a2s.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); } }); } }