|
JFileChooser remember the location
I'm trying to get the JFileChooser to remember the location of the previous location opened, and then next time open there, but is doesn't seem to remember.
I have tried to do this using the following method:
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
final JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog(jButton2);
if (theOutString != null){
fc.setCurrentDirectory(new File(theOutString)); }
if(returnVal == JFileChooser.APPROVE_OPTION) {
theOutString = fc.getSelectedFile().getName();
theOutString = fc.getSelectedFile().getPath();
System.out.println("You chose to open this file: " + theOutFile);
jTextField1.setText(theOutString);
}
}
private String theOutString;
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|