KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javacore > ShutDownProgressPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.javacore;
21 import javax.swing.JComponent JavaDoc;
22 import javax.swing.JDialog JavaDoc;
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 /**
29  *
30  * @author Jan Becicka
31  */

32 public class ShutDownProgressPanel extends JDialog JavaDoc {
33
34     private static ShutDownProgressPanel instance = null;
35
36     private ProgressHandle progress;
37     private int currentValue;
38     private int maxValue;
39
40     /** Creates new form UndoProgressPanel */
41     private ShutDownProgressPanel() {
42         //super(WindowManager.getDefault().getMainWindow(),true);
43
setModal(true);
44         initComponents();
45         this.progress = ProgressHandleFactory.createHandle("");//NOI18N
46
jPanel1.add(ProgressHandleFactory.createProgressComponent(progress), java.awt.BorderLayout.CENTER);
47         pack();
48         setBounds(Utilities.findCenterBounds(getSize()));
49         //setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
50
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     /** This method is called from within the constructor to
77      * initialize the form.
78      * WARNING: Do NOT modify this code. The content of this method is
79      * always regenerated by the Form Editor.
80      */

81     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
82
private void initComponents() {
83         jPanel1 = new javax.swing.JPanel JavaDoc();
84         label = new javax.swing.JLabel JavaDoc();
85
86         setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
87         jPanel1.setLayout(new java.awt.BorderLayout JavaDoc());
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     // </editor-fold>//GEN-END:initComponents
99

100     // Variables declaration - do not modify//GEN-BEGIN:variables
101
private javax.swing.JPanel JavaDoc jPanel1;
102     private javax.swing.JLabel JavaDoc label;
103     // End of variables declaration//GEN-END:variables
104

105 }
106
Popular Tags