1 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 22 public class DirPropertyInputHandler extends AbstractFilePropertyInputHandler { 23 24 27 public DirPropertyInputHandler(JFrame frame) { 28 super(frame); 29 } 30 31 34 public static void main(String [] args) { 35 JFrame frame = new JFrame (); 36 frame.show(); 37 AbstractFilePropertyInputHandler inst = new DirPropertyInputHandler(frame); 38 inst.setVisible(true); 39 } 40 41 44 protected ActionListener getBrowseButtonListener() { 45 return new ActionListener () { 46 public void actionPerformed(ActionEvent evt) { 47 JFileChooser chooser = new JFileChooser (); 48 chooser.setApproveButtonText("Select"); 49 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 50 String currentValue = propertyValueTxt.getText(); 51 chooser.setSelectedFile(new File (currentValue)); 52 int returnVal = chooser.showOpenDialog(DirPropertyInputHandler.this); 53 if(returnVal == JFileChooser.APPROVE_OPTION) { 54 propertyValueTxt.setText(chooser.getSelectedFile().toString()); 55 } 56 } 57 }; 58 } 59 } 60 | Popular Tags |