2 Replies Latest reply: Oct 7, 2004 2:24 PM by 807587 RSS

    JFileChooser's file list

    807587
      Hi, I want to create a custom import dialog, and I'd like to reuse the file tree view that JFileChooser has. However, the JFileChooser comes with tons of other components that I don't want: buttons, the "name" text field and label, and the "type" combo box and label. I could just reverse engineer JFileChooser and set those JComponents to setVisible(false), but there must be a better way to produce the file tree view that JFileChooser uses... any ideas?
      Thanks!
        • 1. Re: JFileChooser's file list
          807587
          http://forum.java.sun.com/thread.jsp?forum=57&thread=470560
          • 2. Re: JFileChooser's file list
            807587
            There were 2 ideas discussed in that thread. One was to use

            JFileChooser fc = new JFileChooser();JPanel whitebox = (JPanel)((Container)fc.getComponent(1)).getComponent(0);

            ... This is platform-specific, since it relies on the specific file chooser L&F.

            The other idea was to use a JTree to display the whole contents of the user's computer. The problem is that the JTree takes forever to create on a large sized hard drive, since it actually reads the entire user's hard drive. I could recode it and lazily create the JTree nodes.

            But what I actually want is something equivalent to the "white panel" from the JFileChooser: the contents of one directory, in a list/table, where double clicking on a folder changes the view to that directory. Does this not exist anywhere?