Here you can find the source of dispose(final JFrame frame)
public static void dispose(final JFrame frame)
//package com.java2s; //License from project: Open Source License import javax.swing.*; public class Main { /**/*from ww w . j a va 2 s.c o m*/ * Schedule disposal of a frame (async). */ public static void dispose(final JFrame frame) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (frame.isDisplayable()) frame.dispose(); } }); } }