• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Save as dialog box question

 
Antigoni Splash
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Antigoni Splash
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That works just fine for me. What is not working with that code?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file needs to exist in the currently displayed location to be selected
 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it doesn't. How else could you save to new files?
 
Antigoni Splash
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file doesn't have to exist i was just placing the command in a wrong place!
Thanks!
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic