1 package net.sf.jhylafax; 2 3 import java.io.File; 4 import org.xnap.commons.gui.FileChooserPanel; 5 import org.xnap.commons.util.QuotedStringTokenizer; 6 7 public class ExecutableChooserPanel extends FileChooserPanel { 8 9 10 public ExecutableChooserPanel(File file, int columns) { 11 super(file, columns); 12 } 13 14 public ExecutableChooserPanel(int columns) { 15 super(columns); 16 } 17 18 @Override 19 public File getFile() { 20 QuotedStringTokenizer t = new QuotedStringTokenizer(getTextField().getText()); 21 return (t.hasMoreTokens()) ? new File(t.nextToken()) : new File(""); 22 } 23 24 @Override 25 public void setFile(File file) { 26 if (file == null) { 27 getTextField().setText(""); 28 } 29 else if (file.getAbsolutePath().contains(" ")) { 30 getTextField().setText("\"" + file.getAbsolutePath() + "\""); 31 } 32 else { 33 getTextField().setText(file.getAbsolutePath()); 34 } 35 } 36 37 }