Here you can find the source of setWindowListenerDispose(JFrame frame)
public static void setWindowListenerDispose(JFrame frame)
//package com.java2s; import javax.swing.JFrame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class Main { public static void setWindowListenerDispose(JFrame frame) { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { evt.getWindow().dispose(); }//from w w w . java 2s. c om }); } }