View Javadoc

1   /*
2    * Created on 17-Jan-2005
3    *
4    * @todo To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package uk.ac.roe.antigen.dialogs;
8   
9   import java.awt.event.ActionEvent;
10  import java.awt.event.ActionListener;
11  import java.io.File;
12  
13  import javax.swing.JFileChooser;
14  import javax.swing.JFrame;
15  /***
16   * @author jdt
17   *
18   * @todo To change the template for this generated type comment go to
19   * Window - Preferences - Java - Code Style - Code Templates
20   */
21  public class FilePropertyInputHandler extends AbstractFilePropertyInputHandler {
22  
23  	/***
24  	 * @param frame
25  	 */
26  	public FilePropertyInputHandler(JFrame frame) {
27  		super(frame);
28  	}
29      
30      /***
31      * Auto-generated main method to display this JDialog
32      */
33      public static void main(String[] args) {
34          JFrame frame = new JFrame();
35          frame.setVisible(true);
36          AbstractFilePropertyInputHandler inst = new FilePropertyInputHandler(frame);
37          inst.setVisible(true);
38      }
39  
40  	/***
41  	 * @return
42  	 */
43  	protected ActionListener getBrowseButtonListener() {
44  		return new ActionListener() {
45  	        public void actionPerformed(ActionEvent evt) {
46  	              JFileChooser chooser = new JFileChooser();
47  	              String currentValue = propertyValueTxt.getText();
48                    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
49  	              chooser.setSelectedFile(new File(currentValue));
50  	                int returnVal = chooser.showOpenDialog(FilePropertyInputHandler.this);
51  	                if(returnVal == JFileChooser.APPROVE_OPTION) {
52  	                    propertyValueTxt.setText(chooser.getSelectedFile().toString());
53  	                }
54  	        }
55  	    };
56  	}
57  }