KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > persistence > wizard > fromdb > ProgressPanel


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.j2ee.persistence.wizard.fromdb;
21 import java.awt.BorderLayout JavaDoc;
22 import java.awt.Dialog JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import javax.swing.JComponent JavaDoc;
25 import org.openide.DialogDescriptor;
26 import org.openide.DialogDisplayer;
27
28 // XXX remove this class when possible and try to use EventRequestProcessor
29
// instead
30

31 /**
32  *
33  * @author Martin Adamek
34  */

35 public class ProgressPanel extends javax.swing.JPanel JavaDoc {
36     
37     private Dialog JavaDoc dialog;
38     
39     /** Creates new form ProgressPanel */
40     public ProgressPanel() {
41         initComponents();
42     }
43     
44     public void open(JComponent JavaDoc progressComponent, String JavaDoc title) {
45         holder.add(progressComponent, BorderLayout.CENTER);
46         try {
47             DialogDescriptor dd = new DialogDescriptor(
48                 this,
49                 title,
50                 true,
51                 new Object JavaDoc[0],
52                 DialogDescriptor.NO_OPTION,
53                 DialogDescriptor.DEFAULT_ALIGN,
54                 null,
55                 null
56                 );
57             dialog = DialogDisplayer.getDefault().createDialog(dd);
58             dialog.setVisible(true);
59         } finally {
60             if (dialog != null) {
61                 dialog.dispose();
62             }
63         }
64         
65     }
66     
67     public void close() {
68     if (dialog != null) {
69         dialog.setVisible(false);
70         dialog.dispose();
71     }
72     }
73     
74     public void setText(String JavaDoc text) {
75         info.setText(text);
76     }
77     
78     String JavaDoc getText() {
79         return info.getText();
80     }
81     
82     /** This method is called from within the constructor to
83      * initialize the form.
84      * WARNING: Do NOT modify this code. The content of this method is
85      * always regenerated by the Form Editor.
86      */

87     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
88
private void initComponents() {
89         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
90
91         info = new javax.swing.JLabel JavaDoc();
92         holder = new javax.swing.JPanel JavaDoc();
93
94         setLayout(new java.awt.GridBagLayout JavaDoc());
95
96         info.setText(" ");
97         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
98         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
99         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 11, 11);
100         add(info, gridBagConstraints);
101
102         holder.setLayout(new java.awt.BorderLayout JavaDoc());
103
104         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
105         gridBagConstraints.gridx = 0;
106         gridBagConstraints.gridy = 1;
107         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
108         gridBagConstraints.weightx = 1.0;
109         gridBagConstraints.weighty = 1.0;
110         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 11, 11);
111         add(holder, gridBagConstraints);
112
113     }// </editor-fold>//GEN-END:initComponents
114

115     
116     // Variables declaration - do not modify//GEN-BEGIN:variables
117
private javax.swing.JPanel JavaDoc holder;
118     private javax.swing.JLabel JavaDoc info;
119     // End of variables declaration//GEN-END:variables
120

121     public Dimension JavaDoc getPreferredSize() {
122         Dimension JavaDoc orig = super.getPreferredSize();
123         return new Dimension JavaDoc(500, orig.height);
124     }
125     
126 }
127
Popular Tags