• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

FileDialog for multiple file selection

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,I just want to open a FileDialog to Open more than one file at a time.For eg. in winamp to add mp3 files to the playlist we are able to select even all files of the folder.I want to select some or all files of a folder and add it to a listbox.Again to choose directory as in winamp to add Directory to the playlist I want to add all files of a specific folder using select directory.Please mail to me as soon as possible
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only way I know how to do something like that (there is probably a better way) is to allow multiple files to be selected and then getSelectedFiles(File[] someName) throws them into an array of files.
As far as selected a DIR instead of a file, I really don't know, unless you use the FileNameFilter and filter out all but directories.
Good Luck.

------------------
Happy Coding,
Gregg Bolinger
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Gregg, but the problem is not how to get the files selected,but how to select multiple files.when I use ctrl+ to select multiple files the previous slection is lost,even shift+ doesn't work in a FileDialog box.So please help me out to get this job done.If possible attach me a piece of sample code.Urgent please.
better suggestion
Netharam
[This message has been edited by netharam ram (edited September 01, 2001).]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in order to open a FileDialog with the option to choose more than one file you should create the FileDialog with SWT.MULTI style:

FileDialog dialog = new FileDialog(shell,SWT.MULTI);

and then get the results using:

String firstFile = dialog.open();
if(firstFile != null){
String[] files = dialog.getFileNames();
}


Guy
 
Sheriff
Posts: 22684
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Guy!

You probably missed that a) this question is about java.awt.FileDialog, not the SWT FileDialog, and b) netharam ram probably didn't wait 10 years for an answer
 
Guy Weiss
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob!

I was trying to find a way to multiselect using SWT FileDialog and during my search I saw this quistion..
When I found a solution, I've added it to this post so if someone will google it in about 10 years from now, he'll be able to see the answer
 
Rob Spoor
Sheriff
Posts: 22684
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And that's exactly why we don't disapprove of kicks like this. The only reason I replied was because of the AWT vs SWT issue, but people looking for answers will of course also find this thread if they are looking for an SWT answer.
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic