Results 1 to 3 of 3
  1. #1
    cocobean is offline Member
    Join Date
    Jul 2011
    Rep Power

    Default OS-independently display a file system in a JTree view

    Hi everyone,

    I've come across numerous references regarding the basics of how to create a JTree file system display, but is there a good reference for building one that will successfully display the file system regardless of whether the application is executed on OS X, Linux, or Windows? Is something like that even supported using the Swing library?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    I guess you would make a TreeModel subclass the implementation of whose methods would depend heavily on a FileSystemView instance supplied when it was created. You would probably want a subclass of DefaultTreeCellRenderer that would rely on the file system view to display labels and icons appropriately.

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power


    Google "JTree file system"...there are many code examples which demonstrates how to use a JTree to display the file system, and if you use the File class it should be relatively straightforward. You would need to define what the root of the tree is could define this for the platform, or use the System.getProperty("user.home");

Similar Threads

  1. JTree only display .txt
    By collin389 in forum AWT / Swing
    Replies: 2
    Last Post: 12-04-2009, 09:50 PM
  2. How to display all TreePath's in JTree?
    By sergey in forum AWT / Swing
    Replies: 2
    Last Post: 11-05-2009, 06:09 AM
  3. Replies: 1
    Last Post: 01-16-2009, 05:44 PM
  4. How to display a file system in a JTree view
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:43 PM
  5. how to display data in Jtree
    By paty in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 12:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts