B4J Question DirectoryChooser - show Files?

Discussion in 'B4J Questions' started by Patent, Aug 7, 2018.

  1. Patent

    Patent Member Licensed User

    Hi community.

    I want to choose a Directory with the build in DirectoryChooser.
    So far so good.
    Problem or wish is:
    In this "Dialog" i want to see also the files, so i can decide which Directory i will select!!
    Like with the Filechooser, but there i cant choose a Directory.

    Is this not possible, or do i miss something?

  2. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible. You can use the FileChooser and get the folder from the selected file, with File.GetFileParent.
    ShaneG30 and Patent like this.
  3. Patent

    Patent Member Licensed User

    thanks erel for your hint.
    thats not exactly what i want, so i tried it with the swing filechooser.
    works roughly perfect, but one thing:
    as it should, it is a "modal" dialog.
    but because of no fx, it "blocks" the main thread. this has no negative effect, but the mainform becomes white with -no response- while the dialog is open.
    its more an optical drawback. no cpu load.
    is there a possibility to avoid this?


    Dim jframe As JavaObject
    Dim jfilechooser As JavaObject
    "setFileSelectionMode",Array(2))        'be able to select files or directories
    Log(jfilechooser.RunMethod("getSelectedFile",Null))            'null or fullpath
  4. Erel

    Erel Administrator Staff Member Licensed User

    Why can't you use the JFX FileChooser?
  5. Patent

    Patent Member Licensed User

    all in all i want to choose a directory.
    when this dir is empty i cant choose it with filechooser and its not the best thing to tell the user "choose a file to select the directory".
    directorychooser should be ok, but i want to see the files in the directories.
    the option to do this was just available in the old swing-chooser :(
  6. Erel

    Erel Administrator Staff Member Licensed User

    I see. I don't have any suggestion about the message queue processing. Never tried it.
  7. MicroDrie

    MicroDrie Member Licensed User

    Hi Patent,

    Maybe you can still use the following code which works for me. It is based on the FileChosen and a comment from Erel; which I found on one of the questions on the forum. The global variable DirPath function is to bring the user back to his previous directory choice.
    Dim FileChosen As String
    FileChosen = fc.ShowOpen(Mainform)
    '   We can use the FileChooser and get the folder from the selected file, with File.GetFileParent.
    Filename1 = FileChosen.Trim
    '   Divide directory and filename
    DirPath = File.GetFileParent(Filename1)
    Filename1 = Filename1.Replace(DirPath, 
  8. Patent

    Patent Member Licensed User

    thank you MicroDrive for your Suggestion.
    But the thing was that i want to choose a Directory. see post #5.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice