1 7 package net.sourceforge.ejtools.deploy; 8 9 import java.awt.BorderLayout ; 11 import java.awt.Dimension ; 12 import java.awt.Toolkit ; 13 14 import javax.swing.ImageIcon ; 15 import javax.swing.JLabel ; 16 import javax.swing.JPanel ; 17 import javax.swing.JProgressBar ; 18 import javax.swing.JWindow ; 19 import javax.swing.SwingUtilities ; 20 21 28 public class SplashWindow extends JWindow 29 { 30 31 protected JPanel panel = null; 32 33 protected JLabel message = null; 34 35 protected JProgressBar progressBar = null; 36 37 protected int length = 0; 38 39 40 46 public SplashWindow(String message, int length) 47 { 48 this.length = length; 49 this.message = new JLabel (message); 50 this.createPanel(); 51 this.setContentPane(panel); 52 this.pack(); 53 54 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 55 this.setLocation(screen.width / 2 - this.getSize().width / 2, screen.height / 2 - this.getSize().height / 2); 56 } 57 58 59 64 public void progress(String message) 65 { 66 this.message.setText(message); 67 68 int value = this.progressBar.getValue(); 69 value++; 70 this.progressBar.setValue(value); 71 72 SwingUtilities.invokeLater( 73 new Runnable () 74 { 75 public void run() 76 { 77 repaint(); 78 } 79 }); 80 } 81 82 83 84 protected void createPanel() 85 { 86 panel = new JPanel (new BorderLayout ()); 87 88 panel.add("North", new JLabel (new ImageIcon (getClass().getResource("/images/logo.png")))); 90 91 panel.add("Center", message); 93 94 progressBar = new JProgressBar (0, this.length); 96 progressBar.setValue(0); 97 progressBar.setStringPainted(false); 98 progressBar.setBorderPainted(false); 99 panel.add("South", progressBar); 100 } 101 } 102 103 104 | Popular Tags |