• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listing files from a folder

 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • 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: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic