1 package com.bonevich.erj.ui;
2
3 import com.bonevich.erj.ErjConstants;
4 import com.bonevich.util.ResourceUtilities;
5
6 import org.tigris.gef.base.Globals;
7 import org.tigris.gef.ui.IStatusBar;
8
9 import java.awt.*;
10 import javax.swing.*;
11
12 public final class Splash extends JFrame
13 implements IStatusBar, ErjConstants
14 {
15 private JLabel _statusLabel = new JLabel(" ");
16 private JProgressBar _progressBar = new JProgressBar();
17
18 public Splash(String title)
19 {
20 super(title);
21
22 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
23 setLocation(
24 screen.width / 2 - ICON_SPLASH.getIconWidth() / 2,
25 screen.height / 2 - ICON_SPLASH.getIconHeight() / 2
26 );
27
28 JLabel splashLabel = new JLabel(EMPTY_STR);
29 splashLabel.setIcon(ICON_SPLASH);
30
31 _progressBar.setMinimum(0);
32 _progressBar.setMaximum(100);
33 _progressBar.setMinimumSize(new Dimension(100,20));
34
35 JPanel statusPanel = new JPanel();
36 statusPanel.setLayout(new BorderLayout());
37 statusPanel.add(_statusLabel, BorderLayout.CENTER);
38 statusPanel.add(_progressBar, BorderLayout.EAST);
39
40 JPanel splashPanel = new JPanel();
41 splashPanel.setLayout(new BorderLayout(0, 0));
42 splashPanel.setBorder(BorderFactory.createEtchedBorder());
43 splashPanel.add(splashLabel, BorderLayout.CENTER);
44 splashPanel.add(statusPanel, BorderLayout.SOUTH);
45 setContentPane(splashPanel);
46
47 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
48 setResizable(false);
49 pack();
50 }
51
52 //////////////////////////////////////////////////////////
53 // IStatusBar implementation
54 /*** Display a status message in the status bar*/
55 public void showStatus(String msg)
56 {
57 _statusLabel.setText(msg);
58 }
59
60 /*** Set status bar in Globals if we are visible*/
61 public void setVisible(boolean isVisible)
62 {
63 super.setVisible(isVisible);
64 if (isVisible)
65 {
66 Globals.setStatusBar(this);
67 }
68 }
69
70 /*** Display a percentage of progress in the progress bar*/
71 public void showProgress(int percent)
72 {
73 _progressBar.setValue(percent);
74 }
75
76 } /*** end class Splash */
This page was automatically generated by Maven