jQuery in Action, 2nd edition
The moose likes Swing / AWT / SWT and the fly likes How to make a JTree show restricted file hiearchies Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "How to make a JTree show restricted file hiearchies" Watch "How to make a JTree show restricted file hiearchies" New topic
Author

How to make a JTree show restricted file hiearchies

Cody Long
Ranch Hand

Joined: Jan 01, 2009
Posts: 95
I need to make a jtree display disabled/hidden file hiarchies. any idea how to do this?


Duct tape is like the Force. It has a dark side, a light side, and it binds the whole universe together.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8441

Um..what is a disabled file?
The java.io.File already has a convenient isHidden() method.

Pseudo code
1) Start with a root
2) Iteratively extract list of all children under that root
3) Define parent child relationships by creating tree nodes from the files
4) Create a JTree from the nodes and display it

In such scenarios, recursion is always helpful and elegant.
The java.io.File is your friend here.
Check out File#listRoots(), File#listFiles(), File#isDirectory(), File#isHidden()

In case you want to know about tree creation, check this out http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Cody Long
Ranch Hand

Joined: Jan 01, 2009
Posts: 95
disabled = not allowed access because admin doesnt allow you to.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Then you can't read those period. The operating system is blocking your access, and there is nothing Java can do about that.

You shouldn't even try. If your system admins blocked those folders then they most likely have had a very good reason to do so. If they haven't, ask them to give you permission.

Note: I'm working very closely with our system admin so I'm biased.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8441

Is your question about retrieving files not accessible to you or is it about display the file structure as a tree?
Cody Long
Ranch Hand

Joined: Jan 01, 2009
Posts: 95
both. i want to show the files and be able to open/retrieve them.
Cody Long
Ranch Hand

Joined: Jan 01, 2009
Posts: 95
Rob Prime wrote:Note: I'm working very closely with our system admin so I'm biased.

lol

Rob Prime wrote: Then you can't read those period. The operating system is blocking your access, and there is nothing Java can do about that.

wel that sucks

Rob Prime wrote: You shouldn't even try. If your system admins blocked those folders then they most likely have had a very good reason to do so. If they haven't, ask them to give you permission.

i am doing this for school. i need to acess some files, copy them and such.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Have you tried asking the sysadmins if you can get access to them? If they say no, talk to your professor. If he doesn't back you up you probably don't really need them.
Cody Long
Ranch Hand

Joined: Jan 01, 2009
Posts: 95
yeah... that wont hapen...
Cody Long
Ranch Hand

Joined: Jan 01, 2009
Posts: 95
but i just realized i can use linux to acess anything i want to that is on the hard drive..... still working on the network
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to make a JTree show restricted file hiearchies
 
Similar Threads
saving JTree
jtree and database
JTree
JTree
Refreshing JTree