Here you can find the source of runModalProcess(String title, final Runnable runnable)
public static void runModalProcess(String title, final Runnable runnable)
//package com.java2s; /*// ww w. j a v a2 s. co m * Copyright (C) 2012 Brendan Robert (BLuRry) brendan.robert@gmail.com. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ import java.awt.BorderLayout; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; public class Main { public static void runModalProcess(String title, final Runnable runnable) { // final JDialog frame = new JDialog(Emulator.getFrame()); final JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); final JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new BorderLayout()); contentPane.add(new JLabel(title), BorderLayout.NORTH); contentPane.add(progressBar, BorderLayout.CENTER); // frame.setContentPane(contentPane); // frame.pack(); // frame.setLocationRelativeTo(null); // frame.setVisible(true); // // new Thread(() -> { // runnable.run(); // frame.setVisible(false); // frame.dispose(); // }).start(); } }