1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/**
* Title: ProAlign<p>
* Description: <p>
* Copyright: Copyright (c) Ari Loytynoja<p>
* License: GNU GENERAL PUBLIC LICENSE<p>
* @see http://www.gnu.org/copyleft/gpl.html
* Company: ULB<p>
* @author Ari Loytynoja
* @version 1.0
*/
package proalign;
import javax.swing.JFileChooser;
import java.awt.Component;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
public class OpenFolderChooser extends JFileChooser {
Component parent;
String txt;
OpenFolderChooser(Component parent, String txt) {
this.parent = parent;
this.txt = txt;
}
String openFile() {
String filepath = new String("");
JFileChooser jfc = new JFileChooser(ProAlign.folderPath);
jfc.setFileSelectionMode(1);
int returnValue = jfc.showDialog(parent, txt);
if(returnValue == JFileChooser.APPROVE_OPTION) {
File path;
if (jfc.getCurrentDirectory().toString().endsWith(File.separator)) {
path = new File(jfc.getCurrentDirectory().toString()
+ jfc.getSelectedFile().getName());
} else {
path = new File(jfc.getCurrentDirectory().toString()
+ File.separator + jfc.getSelectedFile().getName());
}
filepath = path.toString();
}
return filepath;
}
}
|