• Post Reply Bookmark Topic Watch Topic
  • New Topic

Directory nodes  RSS feed

 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am implementing an explorer type file manager in swing. There are two panels. The left one is a JTree that maintains a list of the folders and the right panel will display the contents of the directory folders.

I have implemented the TreeModel interface using a Subclass of File for the nodes. It works fine except that a directory that has no subdirectories is shown as expandable, when it has no children. It cannot be a leaf node as it could have children so my isLeaf() method just returns false. Any suggestions as to how I might solve this problem.

The second question is related to the right hand panel. I wish to show the contents in a JTable with a columns for the icon, file name, size and modified date. How do I display the Icon that would be associated with a file. I am guessing that it may have something to do with the FileSystemView class?
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It cannot be a leaf node as it could have children so my isLeaf() method just returns false. Any suggestions as to how I might solve this problem.


I think the statement above is incorrect, a leaf node merely has no children. node.getAllowsChildren() returns false for nodes that may not have children.

The isLeaf() should return true if the node has no children.

-tad
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!