Here you can find the source of runProgressBar(final Runnable runnable, final JDialog dialog)
Parameter | Description |
---|---|
runnable | the runnable |
dialog | the dialog |
private static void runProgressBar(final Runnable runnable, final JDialog dialog)
//package com.java2s; /*// w w w .j av a 2 s . c o m *------------------- * The ProgressBarUtil.java is part of ASH Viewer *------------------- * * ASH Viewer is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASH Viewer 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ASH Viewer. If not, see <http://www.gnu.org/licenses/>. * * Copyright (c) 2009, Alex Kardapolov, All rights reserved. * */ import javax.swing.JDialog; public class Main { /** * Run progress bar. * * @param runnable the runnable * @param dialog the dialog */ private static void runProgressBar(final Runnable runnable, final JDialog dialog) { Thread worker = new Thread() { @Override public void run() { try { runnable.run(); } catch (Throwable e) { e.printStackTrace(); } finally { dialog.dispose(); } return; } }; worker.start(); dialog.setVisible(true); } }