001package jmri.util.swing;
002
003import java.awt.BorderLayout;
004import java.awt.Dimension;
005import javax.swing.BorderFactory;
006import javax.swing.JDialog;
007import javax.swing.JFrame;
008import javax.swing.JProgressBar;
009
010/**
011 * Creates a simple "indeterminate" busy spinner dialog...
012 *
013 * @author   Mark Underwood Copyright (C) 2011
014 *
015 */
016public class BusyDialog extends JDialog {
017
018    JFrame frame;
019    JProgressBar pbar;
020
021    public BusyDialog(JFrame frame, String title, boolean modal) {
022        super(frame, title, modal);
023        this.frame = frame;
024        initComponents();
025    }
026
027    public void initComponents() {
028
029        setLocationRelativeTo(frame);
030        setPreferredSize(new Dimension(200, 100));
031        setMinimumSize(new Dimension(200, 100));
032        setLayout(new BorderLayout(10, 10));
033
034        pbar = new JProgressBar();
035        pbar.setIndeterminate(true);
036        pbar.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
037        //pbar.setBorderPainted(true);
038        this.add(pbar, BorderLayout.CENTER);
039    }
040
041    public void start() {
042        this.pack();
043        this.setVisible(true);
044        this.getContentPane().paintAll(pbar.getGraphics());
045    }
046
047    public void finish() {
048        this.dispose();
049
050    }
051
052    // Unused, for now.  Commented out to avoid the compiler warning.
053    //private static final Logger log = LoggerFactory.getLogger(VSDecoderPane.class);
054}