1 19 20 package com.sslexplorer.server; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Color ; 24 import java.net.URL ; 25 26 import javax.swing.BorderFactory ; 27 import javax.swing.ImageIcon ; 28 import javax.swing.JPanel ; 29 import javax.swing.JProgressBar ; 30 31 import com.sslexplorer.boot.BootProgressMonitor; 32 import com.sslexplorer.boot.Util; 33 34 35 40 public class SwingBootProgressMonitor implements BootProgressMonitor { 41 42 private SplashWindow monitor; 43 private JProgressBar progress; 44 private String message; 45 46 50 public SwingBootProgressMonitor() { 51 URL u = getClass().getResource("/images/enterprise.png"); 52 if(u == null) { 53 u = getClass().getResource("/images/community.png"); 54 } 55 if(u != null) { 56 ImageIcon icon = new ImageIcon (u); 57 58 progress = new JProgressBar (0, 100); 60 progress.setBackground(Color.white); 61 progress.setForeground(Color.black); 62 progress.setStringPainted(true); 63 JPanel pp = new JPanel (new BorderLayout ()); 64 pp.setBorder(BorderFactory.createEmptyBorder(2, 5, 5, 5)); 65 pp.setOpaque(true); 66 pp.setBackground(Color.white); 67 pp.setForeground(Color.black); 68 pp.add(progress, BorderLayout.CENTER); 69 70 monitor = new SplashWindow(null, icon == null ? null : icon.getImage(), 100000, pp); 72 monitor.setBackground(Color.white); 73 monitor.setForeground(Color.black); 74 monitor.setVisible(true); 75 monitor.setBorder(BorderFactory.createLineBorder(Color.black)); 76 } 77 } 78 79 82 public void updateMessage(String message) { 83 if(monitor != null) { 84 this.message = message; 85 progress.setString(message + " - " + progress.getValue() + "%"); 86 } 87 } 88 89 92 public void updateProgress(int percent) { 93 if(monitor != null) { 94 progress.setString(message == null ? percent + "%" : ( message + " - " + percent + "%") ); 95 progress.setValue(percent); 96 } 97 } 98 99 102 public void dispose() { 103 if(monitor != null) { 104 monitor.hide(); 105 } 106 } 107 108 } 109 | Popular Tags |