java - How to open directly a directory(location) with JFileChooser? -
is there possibility open preconfigured directory directly in jfilechooser opendialog ?
i tried set directory follow code:
file fn = new file("c://users//me//documents//test"); openfile = new jfilechooser(); openfile.showopendialog(f); openfile.setcurrentdirectory(fn); fto = openfile.getselectedfile(); loadfile(openfile.getselectedfile());
it can go this:
string startpath = "c://users//me//documents//test"; jfilechooser openfile = new jfilechooser(new file(startpath)); openfile.showopendialog(null); file filechoosen = openfile.getselectedfile(); string filename = openfile.getselectedfile().getname(); string filepathandname = openfile.getselectedfile().getpath(); //do want variables... system.out.println(filename); system.out.println(filepathandname);
Comments
Post a Comment