Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2004

Tip: Looking for answers? Try searching our database.

FileDialog.setDirectory("") ?

Thread view: 
Dado - 26 Sep 2004 09:47 GMT
...
       FileDialog fileDialog = null;

      if (fileDialog == null) {
        fileDialog = new FileDialog(this,"Otvori");
      }

      fileDialog.setMode(FileDialog.LOAD);
      fileDialog.setDirectory("c:/base/");
      fileDialog.setFile("*.hsql");
      fileDialog.show();
...

Although I setDirectory to a "c:/base/" (which exist), my fileDialog don't
open in a
main directory of my application (in Win98) or in last opened (in a XP).
Why?
Andrew Thompson - 26 Sep 2004 10:26 GMT
> Although I setDirectory to a "c:/base/" (which exist),
> my fileDialog don't open in a main directory of my application

Try this sample..
<sscce>
import java.awt.*;
import java.io.File;

public class DirectoryDialog {

  public static void main(String args[]) {
     Frame f = new Frame();
     FileDialog fd = new FileDialog(f);
     fd.setVisible(true);

     fd.setDirectory(System.getProperty("user.home"));
     fd.setVisible(true);

     String myDirectory = "c:/base/";
     File file = new File(myDirectory);
     System.out.println("Directory: " + file +
        " / " + file.exists());

     fd.setDirectory(myDirectory);
     fd.setVisible(true);
  }
}
</sscce>

HTH

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane

Dado - 28 Sep 2004 09:21 GMT
> > Although I setDirectory to a "c:/base/" (which exist),
> > my fileDialog don't open in a main directory of my application
[quoted text clipped - 33 lines]
> http://www.1point1C.org/  Science & Technology
> http://www.lensescapes.com/  Images that escape the mundane

I got user directory, but although directory "c:/base/" exists
I didn't get it in a FileDialog.
Andrew Thompson - 28 Sep 2004 15:55 GMT
> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message...
>>
>>> Although I setDirectory to a "c:/base/" (which exist),
>>> my fileDialog don't open in a main directory of my application
>>
>> Try this sample..
..
>>       File file = new File(myDirectory);
>>       System.out.println("Directory: " + file +
>>          " / " + file.exists());
..
> I got user directory, but although directory "c:/base/" exists
> I didn't get it in a FileDialog.

Please copy/paste the exact string you got at System.out.println()

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane

Tux - 28 Sep 2004 23:12 GMT
>> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message...
>>>
[quoted text clipped - 11 lines]
>
> Please copy/paste the exact string you got at System.out.println()

OK. I tried .setDirectory(file.toString) and it works.
Thank you on your patience.
Andrew Thompson - 28 Sep 2004 23:22 GMT
> OK. I tried .setDirectory(file.toString) and it works.

Woohoo!  I knew you'd get there.  :-)

> Thank you on your patience.

You're welcome.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.