1 19 20 package org.netbeans.modules.j2ee.persistence.wizard.fromdb; 21 import java.awt.BorderLayout ; 22 import java.awt.Dialog ; 23 import java.awt.Dimension ; 24 import javax.swing.JComponent ; 25 import org.openide.DialogDescriptor; 26 import org.openide.DialogDisplayer; 27 28 31 35 public class ProgressPanel extends javax.swing.JPanel { 36 37 private Dialog dialog; 38 39 40 public ProgressPanel() { 41 initComponents(); 42 } 43 44 public void open(JComponent progressComponent, String title) { 45 holder.add(progressComponent, BorderLayout.CENTER); 46 try { 47 DialogDescriptor dd = new DialogDescriptor( 48 this, 49 title, 50 true, 51 new Object [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 text) { 75 info.setText(text); 76 } 77 78 String getText() { 79 return info.getText(); 80 } 81 82 87 private void initComponents() { 89 java.awt.GridBagConstraints gridBagConstraints; 90 91 info = new javax.swing.JLabel (); 92 holder = new javax.swing.JPanel (); 93 94 setLayout(new java.awt.GridBagLayout ()); 95 96 info.setText(" "); 97 gridBagConstraints = new java.awt.GridBagConstraints (); 98 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 99 gridBagConstraints.insets = new java.awt.Insets (12, 12, 11, 11); 100 add(info, gridBagConstraints); 101 102 holder.setLayout(new java.awt.BorderLayout ()); 103 104 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (0, 12, 11, 11); 111 add(holder, gridBagConstraints); 112 113 } 115 116 private javax.swing.JPanel holder; 118 private javax.swing.JLabel info; 119 121 public Dimension getPreferredSize() { 122 Dimension orig = super.getPreferredSize(); 123 return new Dimension (500, orig.height); 124 } 125 126 } 127 | Popular Tags |