KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > wizard > SchemaTransformProgressPanel


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.abe.wizard;
21
22 import org.openide.*;
23 import org.openide.util.*;
24 import org.openide.windows.*;
25 import java.awt.*;
26 import java.awt.Dialog JavaDoc;
27
28 /**
29  *
30  * @author Ayub Khan
31  */

32 public class SchemaTransformProgressPanel extends javax.swing.JPanel JavaDoc {
33     private static final long serialVersionUID = -483941387931729295L;
34     // Variables declaration - do not modify
35
private javax.swing.JLabel JavaDoc jLabel1;
36     private javax.swing.JProgressBar JavaDoc progressBar;
37     
38     private Dialog JavaDoc dialog;
39     
40     /**
41      *
42      *
43      */

44     public SchemaTransformProgressPanel() {
45         super();
46         initComponents();
47     }
48     
49     /**
50      *
51      *
52      */

53     public DialogDescriptor createDialog(String JavaDoc message) {
54         SchemaTransformProgressPanel panel = new SchemaTransformProgressPanel();
55         DialogDescriptor descriptor = new DialogDescriptor(
56                 panel, NbBundle.getMessage(
57                 SchemaTransformProgressPanel.class,
58                 "MSG_SchemaTransform_ProgressPanel", new Object JavaDoc[]{message})
59                 ); // NOI18N
60

61         final Object JavaDoc[] OPTIONS = new Object JavaDoc[0];
62         descriptor.setOptions(OPTIONS);
63         descriptor.setClosingOptions(OPTIONS);
64         descriptor.setModal(true);
65         descriptor.setOptionsAlign(DialogDescriptor.BOTTOM_ALIGN);
66         
67         dialog = DialogDisplayer.getDefault().createDialog(descriptor);
68         
69         Frame mainWindow = WindowManager.getDefault().getMainWindow();
70         int windowX = mainWindow.getX();
71         int windowY = mainWindow.getY();
72         int windowWidth = mainWindow.getWidth();
73         int windowHeight = mainWindow.getHeight();
74         int dialogWidth = dialog.getWidth();
75         int dialogHeight = dialog.getHeight();
76         int dialogX = (int)(windowWidth/2.0) - (int)(dialogWidth/2.0);
77         int dialogY = (int)(windowHeight/2.0) - (int)(dialogHeight/2.0);
78         
79         dialog.setLocation(dialogX, dialogY);
80         
81         return descriptor;
82     }
83     
84     /**
85      *
86      *
87      */

88     public void showDialog(String JavaDoc message) {
89         assert dialog != null : "invoke createDialog, then call this method";
90         dialog.setVisible(true);
91     }
92     
93     /**
94      *
95      *
96      */

97     public void hideDialog() {
98         if (dialog != null) {
99             dialog.setVisible(false);
100             dialog.dispose();
101             dialog = null;
102         }
103     }
104     
105     /** This method is called from within the constructor to
106      * initialize the form.
107      * WARNING: Do NOT modify this code. The content of this method is
108      * always regenerated by the Form Editor.
109      */

110     private void initComponents() {//GEN-BEGIN:initComponents
111

112         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
113
114         jLabel1 = new javax.swing.JLabel JavaDoc();
115         progressBar = new javax.swing.JProgressBar JavaDoc();
116
117         setLayout(new java.awt.GridBagLayout JavaDoc());
118
119         setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(10, 10, 15, 10)));
120         setMinimumSize(new java.awt.Dimension JavaDoc(100, 38));
121         setPreferredSize(new java.awt.Dimension JavaDoc(250, 55));
122         jLabel1.setText(
123             java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/schema/abe/wizard/Bundle")
124                                     .getString("MSG_SchemaTransform_ProgressPanelMessage")
125         );
126         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
127         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
128         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
129         add(jLabel1, gridBagConstraints);
130
131         progressBar.setIndeterminate(true);
132         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
133         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
134         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
135         gridBagConstraints.weightx = 1.0;
136         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
137         add(progressBar, gridBagConstraints);
138     }//GEN-END:initComponents
139

140 }
141
Popular Tags