java - how to get a JFileChooser to remember a previous folder? -


i'm trying jfilechooser remember location of previous location opened, , next time open there, doesn't seem remember. have open twice: @ first run works fine. @ second run there's still path locked first run. have open jfilechooser dialog twice newer path...

//integrate actionlistener anonymous class this.openitem.addactionlistener(new java.awt.event.actionlistener() {     //initialise actionperformed      @override     public void actionperformed(java.awt.event.actionevent e) {         //generate choose file         this.chooser.setfileselectionmode(jfilechooser.directories_only);         int returnval = this.chooser.showopendialog(pdfcheck.this.openitem);         if (this.theoutstring != null){         this.chooser.setcurrentdirectory(new file(this.theoutstring)); }         if(returnval == jfilechooser.approve_option) {         //theoutstring = fc.getselectedfile().getname();         this.theoutstring = this.chooser.getselectedfile().getpath();         system.out.println("you chose open file: " + this.theoutstring);}         }         private string theoutstring;         private final jfilechooser chooser = new jfilechooser();          }); 

thanks ;-)

problem first show file chooser dialog, , set current directory after that.

you should first set current directory first , show dialog:

if (this.theoutstring != null)     this.chooser.setcurrentdirectory(new file(this.theoutstring)); int returnval = this.chooser.showopendialog(pdfcheck.this.openitem); 

Comments

Popular posts from this blog

mysqli - Php Mysqli_fetch_assoc Error : "Warning: Illegal string offset 'name' in" -

html - Cut text on left side inside button while centering -

plugins - CodeIgniter support on netbeans 8.0 -