1 package de.matthias_burbach.mosaique.swing;
2
3 import java.awt.BorderLayout;
4 import java.awt.Frame;
5
6 import javax.swing.JDialog;
7 import javax.swing.JLabel;
8 import javax.swing.WindowConstants;
9
10 /***
11 * Is a 'Please wait...' dialog displaying an animated gif which mimics a simple
12 * progress bar.
13 *
14 * @author Matthias Burbach
15 */
16 public class WaitDialog extends JDialog {
17 /***
18 * @param owner the <code>Frame</code> from which the dialog is displayed
19 * @param modal true for a modal dialog, false for one that allows
20 * others windows to be active at the same time
21 */
22 public WaitDialog(final Frame owner, final boolean modal) {
23 super(owner, modal);
24 getContentPane().setLayout(new BorderLayout());
25 setTitle("Please wait...");
26 getContentPane().add(
27 new JLabel(SwingHelper.createImageIcon(
28 "mosaique.jpg", "")),
29 BorderLayout.CENTER);
30 getContentPane().add(
31 new JLabel(SwingHelper.createImageIcon("progress.gif", "")),
32 BorderLayout.SOUTH);
33 final int width = 30;
34 final int height = 120;
35 setSize(width, height);
36 setResizable(false);
37 setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
38 if (owner != null) {
39 int x = owner.getX() + ((owner.getWidth() - getWidth()) / 2);
40 int y = owner.getY() + ((owner.getHeight() - getHeight()) / 2);
41 setLocation(x, y);
42 }
43 }
44 }