Java JDialog runProgressBar(final Runnable runnable, final JDialog dialog)

Here you can find the source of runProgressBar(final Runnable runnable, final JDialog dialog)

Description

Run progress bar.

License

Open Source License

Parameter

Parameter Description
runnable the runnable
dialog the dialog

Declaration

private static void runProgressBar(final Runnable runnable, final JDialog dialog) 

Method Source Code

//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);
    }
}

Related

  1. poseInsideScreen(JDialog component)
  2. positionDialogInContainer(JDialog dialog, Container frame, int horizontal, int vertical)
  3. renderDialog(JDialog thedialog, String szMessage, int noffsetx, int noffsety)
  4. resizeDialogToScreen(JDialog dialog)
  5. rptaConfirmDialog(JDialog pJDialog, String pMensaje)
  6. setActionsMenu(JDialog dialog, MenuElement menu)
  7. setCursorFree(JDialog dialog)
  8. setDirty(JDialog dialog, boolean isDirty)
  9. setHelpDialogLoc(JButton odsHelpButton, JDialog helpDialog)