KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > io > swing > FileComboBoxPanel


1 /*
2  * FileComboBoxPanel.java
3  *
4  * Created on 4. August 2006, 15:36
5  */

6 /*
7  * Copyright 2006 Schlichtherle IT Services
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package de.schlichtherle.io.swing;
23
24 import de.schlichtherle.io.ArchiveDetector;
25 import de.schlichtherle.io.File;
26
27 import java.awt.EventQueue JavaDoc;
28
29 import javax.swing.JFrame JavaDoc;
30 import javax.swing.WindowConstants JavaDoc;
31
32 /**
33  * @author Christian Schlichtherle
34  * @since TrueZIP 6.2
35  * @version @version@
36  */

37 public class FileComboBoxPanel extends javax.swing.JPanel JavaDoc implements Runnable JavaDoc {
38
39     /** Creates new form FileComboBoxPanel */
40     public FileComboBoxPanel() {
41         initComponents();
42     }
43
44     /** Creates new form FileComboBoxPanel */
45     public FileComboBoxPanel(java.io.File JavaDoc directory) {
46         initComponents();
47         setDirectoryImpl(directory);
48     }
49
50     /** This method is called from within the constructor to
51      * initialize the form.
52      * WARNING: Do NOT modify this code. The content of this method is
53      * always regenerated by the Form Editor.
54      */

55     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
56
private void initComponents() {
57         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
58
59         final javax.swing.JLabel JavaDoc jLabel1 = new javax.swing.JLabel JavaDoc();
60         final javax.swing.JComboBox JavaDoc box1 = new javax.swing.JComboBox JavaDoc();
61         final javax.swing.JComboBox JavaDoc box2 = new javax.swing.JComboBox JavaDoc();
62
63         browser1.setComboBox(box1);
64         browser2.setComboBox(box2);
65
66         setLayout(new java.awt.GridBagLayout JavaDoc());
67
68         setBorder(javax.swing.BorderFactory.createEmptyBorder(15, 15, 15, 15));
69         jLabel1.setFont(new java.awt.Font JavaDoc("Dialog", 1, 12));
70         jLabel1.setText("Please start entering a file name anywhere...");
71         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
72         gridBagConstraints.gridx = 0;
73         gridBagConstraints.gridy = 1;
74         gridBagConstraints.insets = new java.awt.Insets JavaDoc(50, 0, 0, 0);
75         add(jLabel1, gridBagConstraints);
76
77         box1.setEditable(true);
78         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
79         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
80         add(box1, gridBagConstraints);
81
82         box2.setEditable(true);
83         box2.setModel(box1.getModel());
84         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
85         gridBagConstraints.gridx = 0;
86         gridBagConstraints.gridy = 2;
87         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
88         gridBagConstraints.insets = new java.awt.Insets JavaDoc(50, 0, 0, 0);
89         add(box2, gridBagConstraints);
90
91     }// </editor-fold>//GEN-END:initComponents
92

93     /**
94      * Getter for property directory.
95      * @return Value of property directory.
96      */

97     public java.io.File JavaDoc getDirectory() {
98         return browser1.getDirectory();
99     }
100
101     /**
102      * Setter for property directory.
103      * @param directory New value of property directory.
104      */

105     public void setDirectory(java.io.File JavaDoc directory) {
106         setDirectoryImpl(directory);
107     }
108
109     private void setDirectoryImpl(java.io.File JavaDoc directory) {
110         browser1.setDirectory(directory);
111         browser2.setDirectory(directory);
112     }
113
114     public static void main(String JavaDoc[] args) {
115         EventQueue.invokeLater(new FileComboBoxPanel(new File(args[0])));
116     }
117
118     public void run() {
119         final JFrame JavaDoc frame = new JFrame JavaDoc("File name auto completion fun");
120         frame.getContentPane().add(this);
121         frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
122         frame.pack();
123         frame.setLocationRelativeTo(null);
124         frame.setVisible(true);
125     }
126
127     // Variables declaration - do not modify//GEN-BEGIN:variables
128
private final de.schlichtherle.io.swing.FileComboBoxBrowser browser1 = new de.schlichtherle.io.swing.FileComboBoxBrowser();
129     private final de.schlichtherle.io.swing.FileComboBoxBrowser browser2 = new de.schlichtherle.io.swing.FileComboBoxBrowser();
130     // End of variables declaration//GEN-END:variables
131
}
132
Popular Tags