JChooser Save Dialog - Default Title

W

wendy.c.leung

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
 
Z

zero

(e-mail address removed) wrote in @g49g2000cwa.googlegroups.com:
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

Have you tried calling JFileChooser:setSelectedFile(File f) before showing
the dialog?

Let me know if it works.
 
R

Rhino

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!
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
 
V

Vova Reznik

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
Read:

javax.swing.filechooser.FileFilter - for file extension

javax.swing.plaf.basic.BasicFileChooserUI (setFileName(String)) - for
file name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top