This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How i can get Folder Explorer

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

does java has Folder Explorer like windows one (GUI)?
what is api name?
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JFileChooser here
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know file chooser

i am looking for some thing like folder tree
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can customize JFileChooser to show and allow selection of only directories/folders. Check out these JDC Tech Tips on customizing JFileChooser. You can setFileSelectionMode to JFileChooser.DIRECTORIES_ONLY - which allows the user to only select directories, and not files. To not show files at all, you will also need to create a FileFilter that filters out all files and shows all directories and pass it to setFileFilter.
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
listing dirctory as a tree is the target and filechooser does not give this target
 
Sheriff
Posts: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could create your own implementation of javax.swing.tree.TreeModel that deals with Files. For instance, "public int getChildCount(Object parent)" would cast parent to a File, calls listFiles() and returns the length of this array (or 0 if the array is null).

Just one hint: if you go this way, cache the arrays. If not, and you again call listFiles() in "public Object getChild(Object parent, int index)", then you will call listFiles() for each and every node in the tree. I did it this way before, and it took minutes to show a folder with 1000+ files.


You can also use File.listFiles(FileFilter) to limit the files you get as a return value.
 
Let's get him boys! We'll make him read this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic