Hello,
I am using a JFileChooser in my application
to set the location where e certain file should
be saved.
Therefor I have set it to display directories only.
My problem is that the last selected folder is always
removed.
I assume I have missed som vital information but
I can not find out why.
Any help is highly appreciated.
The method is shown below.
.:. rob
--[ code start ]--
protected static String getDirectory( MainFrame mf, File curDir ) {
JFileChooser jfc = new JFileChooser();
jfc.setDialogTitle( "Set destination.." );
jfc.setName( "Set destination" );
jfc.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
jfc.setApproveButtonToolTipText( "Set destination" );
jfc.setApproveButtonText( "Ok" );
jfc.setCurrentDirectory( curDir );
int value = jfc.showSaveDialog( mf );
if( value == JFileChooser.APPROVE_OPTION ) {
return jfc.getCurrentDirectory().getPath();
}
return null;
}
--[ code end ]--
Robert Karlsson - 22 Apr 2004 05:58 GMT
[snip]
> My problem is that the last selected folder is always
> removed.
[snip]
For clarity:
With remove I mean that the String returned from
this method does not include the last selected folder.
cheers, rob
Robert Karlsson - 22 Apr 2004 18:27 GMT
Problem solved, old stupid me
missed the obvious method in the api docs.
If anyone is interested, the code should read:
if( value == JFileChooser.APPROVE_OPTION ) {
return jfc.getSelectedFile().toString();
}
cheers, rob