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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -