• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listing files from a folder

 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I am trying to do -
I want to have a drop-down box at the top from which user can select the desired folder/directory, and the table below will display all the files with their attributes, size type etc. I have managed to finish the Table part iof this succesfully. My question is - "How can I have a drop-down list of folders from which user can select at the top?" Is there any component available in swing which can be customized to display this, I couldn't do it with FileChooser. The list must be displayed all the time in the application, is this feasible using FileChooser?
TIA,
- Manish
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me try to elaborate this -
In short, I want to have the listbox which is situated at top in the JFileChooser dialog in my application. How can I do this?
TIA,
- Manish
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method File.listRoots() diplays the drives present in the system.U can then create a File of the selected item in the Listbox & use new_file.listFiles() to display the files & folders in that drive & if it is a folder then display it else leave it.
Happy middling with java. :
Netharam.
[ February 06, 2002: Message edited by: netharam ram ]
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
Finally, I DID manage to do it the way I wanted, just like JFileChooser dialog. I knew abt the File.listRoots() method, puting folder hierarchically was a problem there. This is what I have done -
1) Made my own ListCellRenderer, depending upon the directoty depth, it decides the location at which the icon is drawn, and displays the file/dir name.
2) If it's a dir, it draws dir icon, if root, root icon and if it's a file a file icon.
3) The directory and its parents are listed by doing FIle.getParent() in a loop until it finds the corresponding root.
Thanks anyway,
- Manish
 
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic