This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Having some problem with FileDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Having some problem with FileDialog " Watch "Having some problem with FileDialog " New topic

Having some problem with FileDialog

vamsi naki
Ranch Hand

Joined: May 18, 2011
Posts: 56
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

Joined: Oct 14, 2005
Posts: 19723

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:

Have you checked out Aspose?
subject: Having some problem with FileDialog
It's not a secret anymore!