Hi,
I would like to have the JChooser Save Dialog display a default title
plus extension when the user first clicks on the Save as option. It is
just like what Microsoft Word does when a user creates a new document
and goes and saves it, and the dialog displays a default title.doc for
the user to use if desired. Is there a way to do this for JChooser
Save Dialog?
Thanks! Any help is much appreciated!
Wendy
zero - 03 Jan 2006 21:12 GMT
wendy.c.leung@gmail.com wrote in news:1136313958.157237.260220
@g49g2000cwa.googlegroups.com:
> Hi,
>
[quoted text clipped - 8 lines]
>
> Wendy
Have you tried calling JFileChooser:setSelectedFile(File f) before showing
the dialog?
Let me know if it works.

Signature
Beware the False Authority Syndrome
wendy.c.leung@gmail.com - 03 Jan 2006 22:23 GMT
Thank you very much! That worked the way I want it!
Wendy
wendy.c.leung@gmail.com - 03 Jan 2006 23:01 GMT
I used JFileChooser:setSelectedFile(File f)
Wendy
Rhino - 03 Jan 2006 21:37 GMT
> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks! Any help is much appreciated!
I assume you mean JFileChooser; there is no JChooser class in the J2SE 1.5.0
API.
I think the method you want is setDialogTitle(), one of the many methods in
JFileChooser. However, I'm not a Word user so I may be mistaken about what
you are trying to do; from the wording of your question, it sounds like you
are more interested in setting the default file name for the file that the
user will save; if that's what you mean, I don't think you can display the
default name directly on the line that shows the File Name; I think the user
needs to click on one of the files displayed in the file list box, THEN the
name of that file is copied to the File Name text field. At least, that's
how it works in a program that I wrote which I just tried to test the
behaviour of JFileChooser.
You may find it helpful to read the Java Tutorial article on the
JFileChooser component; you can find it at
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html.
The JFileChooser article in the API will probably also be useful.
Rhino
Vova Reznik - 03 Jan 2006 21:43 GMT
> Hi,
>
[quoted text clipped - 8 lines]
>
> Wendy
Read:
javax.swing.filechooser.FileFilter - for file extension
javax.swing.plaf.basic.BasicFileChooserUI (setFileName(String)) - for
file name