/Users/lyon/j4p/src/gui/run/DirectoryGui.java

1    package gui.run; 
2     
3    import futils.Futil; 
4     
5    import javax.swing.*; 
6    import java.awt.*; 
7    import java.io.File; 
8    import java.util.Vector; 
9     
10   /** 
11    * Copyright DocJava, inc. User: lyon Date: Aug 19, 2004 Time: 5:27:17 AM 
12    */ 
13   public class DirectoryGui { 
14       private Vector dirVector = new Vector(); 
15    
16       public JPanel getFilePanel(final String prompt) { 
17           JPanel jp = new JPanel(); 
18           jp.setLayout(new BorderLayout()); 
19           jp.setBorder(BorderFactory.createEtchedBorder()); 
20           jp.setName(prompt); 
21           final JLabel directoryLabel = new JLabel("Directories"); 
22           jp.add(new RunButton("...") { 
23               public void run() { 
24                   File f = Futil.getReadDirFile("select a directory"); 
25                   directoryLabel.setText(f.toString()); 
26                   addDirs(f.listFiles()); 
27               } 
28           }, BorderLayout.EAST); 
29    
30    
31           jp.add(directoryLabel, 
32                   BorderLayout.WEST); 
33           return jp; 
34       } 
35    
36    
37       public File[] getDirs() { 
38           File f[] = new File[dirVector.size()]; 
39           dirVector.copyInto(f); 
40           return f; 
41       } 
42    
43       public void addDirs(File f[]) { 
44           for (int i=0;i<f.length;i++) 
45               dirVector.addElement(f[i]); 
46       } 
47   } 
48