fileChooser.setSelectedFile() is not working when i change file filter

hello ,

i am seeing a strange issue with fileChooser.setSelectedFile(),is not setting any filename on filename filed of showsave dialog when i change file filter.

This is working fine when i run my code on WSAD,but the same code is not working if i make executable jar.

The code i am using here is

fileChooser.addPropertyChangeListener(new PropertyChangeListener(){

publicvoid propertyChange(PropertyChangeEvent evt){

if (JFileChooser.FILE_FILTER_CHANGED_PROPERTY.equals(evt.getPropertyName())){

fileFormat=((MyFilter)evt.getNewValue()).getDescription();

fileFormat=fileFormat.substring(fileFormat.indexOf(".")+1,fileFormat.length());

File outFile =new File(fileChooser.getCurrentDirectory()+"//"+new File(getFileName(fileName)+"."+fileFormat));

fileChooser.setCurrentDirectory(fileChooser.getCurrentDirectory());

fileChooser.setSelectedFile(outFile);

}elseif (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(evt.getPropertyName())){

JFileChooser chooser = (JFileChooser)evt.getSource();

File newDir = (File)evt.getNewValue();

fileChooser.setCurrentDirectory(newDir);

fileChooser.setSelectedFile(new File(getFileName(fileName)+"."+fileFormat));

File curDir = chooser.getCurrentDirectory();

}

}

});

please help me to resolvethis issueif anyone aware ofthis problem ASAP.

Thanks in advance.

[2143 byte] By [ram_76uka] at [2007-11-26 16:31:26]
# 1

Your problem sounds to me is related to a faulty resource loading mechanism and not to to the file chooser.

And what is

> File outFile = new File(fileChooser.getCurrentDirectory()+"//"+new File(getFileName(fileName)+"."+fileFormat));

supposed to do? It looks horrible and potentially incorrect.

CeciNEstPasUnProgrammeura at 2007-7-8 22:55:58 > top of Java-index,Java Essentials,Java Programming...
# 2

File outFile = new File(fileChooser.getCurrentDirectory()+"//"+new File(getFileName(fileName)+"."+fileFormat));

here fileChooser.getCurrentDirectory() : will return the current directory

getFileName(filename) : is my private method which return my application specific and unique file name with out any extension.

fileFormat : holds the type of file(ex: txt or csv)

as i said before this is working fine on WSAD,but if i make executable jar then its not working.

ram_76uka at 2007-7-8 22:55:58 > top of Java-index,Java Essentials,Java Programming...
# 3
> as i said before this is working fine on WSAD,but if> i make executable jar then its not working.As I said before this is very likely to be a resource loading issue then.
CeciNEstPasUnProgrammeura at 2007-7-8 22:55:58 > top of Java-index,Java Essentials,Java Programming...
# 4
if it is an issue with resource loading then when i change the directory that time also ,file name field on save dialog should be empty.But that is not happening when i change the directory.please help me out here
ram_76uka at 2007-7-8 22:55:58 > top of Java-index,Java Essentials,Java Programming...
# 5

> please help me out here

I don't know anything about "changing directories".

Help yourself. Grab a debugger or a few strategically placed System.out.println()s and verify that your input to setSelectedFile() is actually what you expect it is. If it isn't, backtrace the cause of the deviation.

CeciNEstPasUnProgrammeura at 2007-7-8 22:55:58 > top of Java-index,Java Essentials,Java Programming...