1 Reply Latest reply: Jul 29, 2011 10:05 AM by 793415 RSS

    display Jar file in Jtree format in swing application

    879048
      Hi,
      i am new to java. I want to display a jar file into Jtree format but not sucessed. I try a lot but unable to display dynamic Jtree. Can any body help me on this issue?
      This is the code that i want to modify for representing a jar file into Jtree.?

      java.io.File;
      import javax.swing.*;
      import javax.swing.tree.*;

      class FileTree {

      public static DefaultMutableTreeNode addTree(String dirname) {
      File file = new File(dirname);
      DefaultMutableTreeNode root = new DefaultMutableTreeNode();
      root.setUserObject(file.getName());
      if (file.isDirectory()) {
      File files[] = file.listFiles();
      for (int i = 0; i < files.length; i++) {
      root.insert(addTree(files.getPath()), i);
      }
      }
      return (root);
      }

      public static void main(String[] args) {
      JFrame frame = new JFrame();
      frame.setSize(300, 400);
      JTree tree = new JTree(addTree("C:/"));
      frame.add(tree);
      frame.setVisible(true);
      }
      }

      Edited by: 876045 on Jul 29, 2011 10:32 AM
        • 1. Re: display Jar file in Jtree format in swing application
          793415
          876045 wrote:
          ..i want to display a jar file into Jtree format but not sucessed. ..
          What did you try?
          .. i try a lot but unable to display dynamic Jtree. ..
          Why dynamic?
          ..can any body help me on this issue
          Can you find your shift key, and apply it once at the start of every sentence? Note that is also pays to add a question mark (?) to questions.