KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > editor > app > gui > TestGenerateDialog


1 /*
2  * TestGenerateDialog.java
3  *
4  * Created on December 3, 2002, 4:53 PM
5  */

6
7 package org.netbeans.test.editor.app.gui;
8
9 import javax.swing.JFileChooser JavaDoc;
10
11 /**
12  *
13  * @author eh103527
14  */

15 public class TestGenerateDialog extends javax.swing.JDialog JavaDoc {
16     
17     String JavaDoc path, packageName;
18     boolean state;
19     
20     /** Creates new form TestGenerateDialog */
21     public TestGenerateDialog(java.awt.Frame JavaDoc parent, String JavaDoc dir) {
22         super(parent, true);
23         initComponents();
24         pack();
25         setPath(dir);
26         String JavaDoc pack=getClass().getPackage().getName();
27         pack=pack.substring(0,pack.lastIndexOf('.'));
28         setPackageName(pack);
29         setLocation(parent.getX()+(parent.getWidth()-getWidth())/2,parent.getY()+(parent.getHeight()-getHeight())/2);
30     }
31     
32     /** This method is called from within the constructor to
33      * initialize the form.
34      * WARNING: Do NOT modify this code. The content of this method is
35      * always regenerated by the Form Editor.
36      */

37     private void initComponents() {//GEN-BEGIN:initComponents
38
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
39
40         jPanel1 = new javax.swing.JPanel JavaDoc();
41         jPanel3 = new javax.swing.JPanel JavaDoc();
42         jPanel4 = new javax.swing.JPanel JavaDoc();
43         jLabel1 = new javax.swing.JLabel JavaDoc();
44         jPanel5 = new javax.swing.JPanel JavaDoc();
45         packageF = new javax.swing.JTextField JavaDoc();
46         jPanel7 = new javax.swing.JPanel JavaDoc();
47         jLabel2 = new javax.swing.JLabel JavaDoc();
48         jPanel6 = new javax.swing.JPanel JavaDoc();
49         pathF = new javax.swing.JTextField JavaDoc();
50         pathB = new javax.swing.JButton JavaDoc();
51         jPanel2 = new javax.swing.JPanel JavaDoc();
52         generateB = new javax.swing.JButton JavaDoc();
53         cancelB = new javax.swing.JButton JavaDoc();
54
55         setTitle("Generate Test Settings");
56         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
57             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
58                 closeDialog(evt);
59             }
60         });
61
62         jPanel3.setLayout(new java.awt.GridBagLayout JavaDoc());
63
64         jPanel4.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.LEFT));
65
66         jLabel1.setText("Package: ");
67         jPanel4.add(jLabel1);
68
69         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
70         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
71         gridBagConstraints.weightx = 1.0;
72         gridBagConstraints.weighty = 1.0;
73         jPanel3.add(jPanel4, gridBagConstraints);
74
75         jPanel5.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.LEFT));
76
77         packageF.setColumns(31);
78         jPanel5.add(packageF);
79
80         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
81         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
82         gridBagConstraints.weightx = 1.0;
83         gridBagConstraints.weighty = 1.0;
84         jPanel3.add(jPanel5, gridBagConstraints);
85
86         jPanel7.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.LEFT));
87
88         jLabel2.setText("Path: ");
89         jPanel7.add(jLabel2);
90
91         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
92         gridBagConstraints.gridx = 0;
93         gridBagConstraints.gridy = 1;
94         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
95         gridBagConstraints.weightx = 1.0;
96         gridBagConstraints.weighty = 1.0;
97         jPanel3.add(jPanel7, gridBagConstraints);
98
99         pathF.setColumns(25);
100         jPanel6.add(pathF);
101
102         pathB.setText("Path");
103         pathB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
104             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
105                 pathBActionPerformed(evt);
106             }
107         });
108
109         jPanel6.add(pathB);
110
111         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
112         gridBagConstraints.gridx = 1;
113         gridBagConstraints.gridy = 1;
114         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
115         gridBagConstraints.weightx = 1.0;
116         gridBagConstraints.weighty = 1.0;
117         jPanel3.add(jPanel6, gridBagConstraints);
118
119         jPanel1.add(jPanel3);
120
121         getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
122
123         jPanel2.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 10, 5));
124
125         generateB.setText("Generate");
126         generateB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
127             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
128                 generateBActionPerformed(evt);
129             }
130         });
131
132         jPanel2.add(generateB);
133
134         cancelB.setText("Cancel");
135         cancelB.addActionListener(new java.awt.event.ActionListener JavaDoc() {
136             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
137                 cancelBActionPerformed(evt);
138             }
139         });
140
141         jPanel2.add(cancelB);
142
143         getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
144
145         pack();
146     }//GEN-END:initComponents
147

148     private void pathBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_pathBActionPerformed
149
// Add your handling code here:
150
setModal(false);
151         JFileChooser JavaDoc dlg=new JFileChooser JavaDoc(path);
152         dlg.setDialogTitle("Select Folder");
153         dlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
154         if (dlg.showDialog(getParent(),"Select") == JFileChooser.APPROVE_OPTION) {
155             setPath(dlg.getSelectedFile().getAbsolutePath());
156         }
157         setModal(true);
158     }//GEN-LAST:event_pathBActionPerformed
159

160     private void generateBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_generateBActionPerformed
161
// Add your handling code here:
162
state=true;
163         path=pathF.getText();
164         packageName=packageF.getText();
165         close();
166     }//GEN-LAST:event_generateBActionPerformed
167

168     private void cancelBActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_cancelBActionPerformed
169
// Add your handling code here:
170
state=false;
171         close();
172     }//GEN-LAST:event_cancelBActionPerformed
173

174     /** Closes the dialog */
175     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
176
close();
177     }//GEN-LAST:event_closeDialog
178

179     private void close() {
180         setVisible(false);
181         dispose();
182     }
183     /** Getter for property path.
184      * @return Value of property path.
185      *
186      */

187     public java.lang.String JavaDoc getPath() {
188         return path;
189     }
190     
191     /** Setter for property path.
192      * @param path New value of property path.
193      *
194      */

195     public void setPath(java.lang.String JavaDoc path) {
196         this.path = path;
197         pathF.setText(path);
198     }
199     
200     /** Getter for property packageName.
201      * @return Value of property packageName.
202      *
203      */

204     public java.lang.String JavaDoc getPackageName() {
205         return packageName;
206     }
207     
208     /** Setter for property packageName.
209      * @param packageName New value of property packageName.
210      *
211      */

212     public void setPackageName(java.lang.String JavaDoc packageName) {
213         this.packageName = packageName;
214         packageF.setText(packageName);
215     }
216     
217     public boolean getState() {
218         return state;
219     }
220     
221     // Variables declaration - do not modify//GEN-BEGIN:variables
222
private javax.swing.JButton JavaDoc pathB;
223     private javax.swing.JButton JavaDoc cancelB;
224     private javax.swing.JPanel JavaDoc jPanel4;
225     private javax.swing.JLabel JavaDoc jLabel1;
226     private javax.swing.JTextField JavaDoc pathF;
227     private javax.swing.JTextField JavaDoc packageF;
228     private javax.swing.JPanel JavaDoc jPanel3;
229     private javax.swing.JLabel JavaDoc jLabel2;
230     private javax.swing.JButton JavaDoc generateB;
231     private javax.swing.JPanel JavaDoc jPanel2;
232     private javax.swing.JPanel JavaDoc jPanel5;
233     private javax.swing.JPanel JavaDoc jPanel7;
234     private javax.swing.JPanel JavaDoc jPanel1;
235     private javax.swing.JPanel JavaDoc jPanel6;
236     // End of variables declaration//GEN-END:variables
237

238 }
239
Popular Tags