aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Save as dialog box question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Save as dialog box question" Watch "Save as dialog box question" New topic
Author

Save as dialog box question

Antigoni Splash
Greenhorn

Joined: Jun 12, 2009
Posts: 10

I have a simple save dialog box as follows:



One question!
I want when the save dialog opens a default filename to appear in the File Name field for example "Hello.txt".
Anyone knows how to do it?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

javax.swing.JFileChooser
You retrieve the selected file using getSelectedFile(). I'll leave it to you to find the method that sets the selected file


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Antigoni Splash
Greenhorn

Joined: Jun 12, 2009
Posts: 10
I' ve tried that beforing posting but i didn't have success i don't know if i am using the command in a wrong way...

I am using the following command:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

That works just fine for me. What is not working with that code?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

The file needs to exist in the currently displayed location to be selected


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

No it doesn't. How else could you save to new files?
Antigoni Splash
Greenhorn

Joined: Jun 12, 2009
Posts: 10
The file doesn't have to exist i was just placing the command in a wrong place!
Thanks!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Rob Prime wrote:No it doesn't. How else could you save to new files?


Oh! Its a save dialog. My bad. You are correct.
Teaches me not to skim over the surface
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Save as dialog box question