Here you can find the source of showModalFrame(final JFrame newFrame, final JFrame owner)
public static void showModalFrame(final JFrame newFrame, final JFrame owner)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import javax.swing.JFrame; public class Main { private static ArrayList<JFrame> reaktivationQue = new ArrayList<>(); public static void showModalFrame(final JFrame newFrame, final JFrame owner) { addToQue(owner);/*from w w w. j ava2 s . co m*/ newFrame.setLocationRelativeTo(owner); owner.setVisible(false); owner.setEnabled(false); newFrame.setVisible(true); newFrame.toFront(); Thread t = new Thread(new Runnable() { public void run() { while (newFrame.isVisible() || !isFirstInQue(owner)) { try { Thread.sleep(200); } catch (InterruptedException e) { } } owner.setVisible(true); owner.setEnabled(true); owner.toFront(); removeFromQue(owner); } }); t.start(); } synchronized private static void addToQue(JFrame frame) { reaktivationQue.add(frame); } synchronized private static boolean isFirstInQue(JFrame frame) { return reaktivationQue.get(reaktivationQue.size() - 1) == frame; } synchronized private static void removeFromQue(JFrame frame) { reaktivationQue.remove(frame); } }