This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having some problem with FileDialog

 
vamsi naki
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I wrote a porgam where there is a textarea and two buttons ,one to load files into the textarea and other button to save what is written in the text area.
I have two problems though
1)The methods filedialog.getDirectory(),filedialog.getFile() return nulll so i am not able to load any file in the text area
2)When i try to save a file ,i used filedialog.setDirectory("C:"+"\" ") and filedialog.setFile("untitled.txt").The problem is it doesnt show the c:\ as the default directory when the dialog box opens .


 
Paul Clapham
Sheriff
Pie
Posts: 20768
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vamsi naki wrote:2)When i try to save a file ,i used filedialog.setDirectory("C:"+"\" ")


In other words, you set the directory to this string:



But you really wanted this string, right?



So you've just got your Java string escaping rules a bit mixed up. You need this code:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic