help needed regarding JFileChooser

hi, this is ravikiran,

I am having a situation where when a save dialog appears, I must provide a default name for the file to be saved in the "File Name" field of save dialog.

Which property of the JFileCooser must be set in order to do this.

help me.

thanx in advance.

[301 byte] By [raviva] at [2007-11-26 16:10:19]
# 1
Take a look at the various "set..." methods. One of them will do what you want.
camickra at 2007-7-8 22:32:44 > top of Java-index,Desktop,Core GUI APIs...
# 2
filteChooser.setSelectedFile(new File(defaultFilename));
watfora at 2007-7-8 22:32:44 > top of Java-index,Desktop,Core GUI APIs...
# 3

hi, thanx for ur reply,

but the code

String path=System.getProperty("user.dir");

filteChooser.setSelectedFile(new File(path+"\\somefile"));

doesn't work for me.

the specified file name doesn't appear in the "File Name" field of save dialog.

help me,

thanx in advance

raviva at 2007-7-8 22:32:44 > top of Java-index,Desktop,Core GUI APIs...
# 4

The is a method to set the directory and a method to set the file name.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.

camickra at 2007-7-8 22:32:44 > top of Java-index,Desktop,Core GUI APIs...
# 5

what i am really trying to do is to provide a default file name in the "File name" field of the save dialog(when ever the save dialog appears the default file name should appear in the "File Name" field of the save dialog)

i tried to do the follwing

JfileChooser fc=new JfileChooser();

fc.setSelectedFile(new File("somefile"));

but it doesn't work for me.

help me regarding this.

thanx in advance.

raviva at 2007-7-8 22:32:44 > top of Java-index,Desktop,Core GUI APIs...
# 6
> but it doesn't work for me.It works for me. Thats why you need to post a SSCCE. We can't see what is wrong based on two lines of code.
camickra at 2007-7-8 22:32:44 > top of Java-index,Desktop,Core GUI APIs...