1 19 20 package org.netbeans.modules.javacore; 21 import javax.swing.JComponent ; 22 import javax.swing.JDialog ; 23 import org.netbeans.api.progress.ProgressHandle; 24 import org.netbeans.api.progress.ProgressHandleFactory; 25 import org.openide.util.NbBundle; 26 import org.openide.util.Utilities; 27 28 32 public class ShutDownProgressPanel extends JDialog { 33 34 private static ShutDownProgressPanel instance = null; 35 36 private ProgressHandle progress; 37 private int currentValue; 38 private int maxValue; 39 40 41 private ShutDownProgressPanel() { 42 setModal(true); 44 initComponents(); 45 this.progress = ProgressHandleFactory.createHandle(""); jPanel1.add(ProgressHandleFactory.createProgressComponent(progress), java.awt.BorderLayout.CENTER); 47 pack(); 48 setBounds(Utilities.findCenterBounds(getSize())); 49 setTitle(NbBundle.getMessage(ShutDownProgressPanel.class, "LBL_ShutDownTitle")); 51 } 52 53 public static synchronized ShutDownProgressPanel getDefault() { 54 if (instance == null) { 55 instance = new ShutDownProgressPanel(); 56 } 57 return instance; 58 } 59 60 public void start(int value) { 61 currentValue = 0; 62 maxValue = value; 63 progress.start(value); 64 } 65 66 public void step() { 67 if (currentValue < maxValue) { 68 progress.progress(++currentValue); 69 } 70 } 71 72 public void stop() { 73 progress.finish(); 74 } 75 76 81 private void initComponents() { 83 jPanel1 = new javax.swing.JPanel (); 84 label = new javax.swing.JLabel (); 85 86 setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); 87 jPanel1.setLayout(new java.awt.BorderLayout ()); 88 89 jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 11, 11)); 90 label.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javacore/Bundle").getString("LBL_ShutDownProgressLabel")); 91 label.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 6, 1)); 92 jPanel1.add(label, java.awt.BorderLayout.NORTH); 93 94 getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); 95 96 pack(); 97 } 98 100 private javax.swing.JPanel jPanel1; 102 private javax.swing.JLabel label; 103 105 } 106 | Popular Tags |