import java.io.*; import java.util.*; import javax.swing.*; /** * @version 1.0 2002-11-23 * @author Takashi KOBAYASHI */ public class memo10ex2 { public static void main( String[] args ) { memo10ex2 ex2 = new memo10ex2(); } public memo10ex2() { File root = new File("./root"); Hashtable ret = new Hashtable(); if( root.isDirectory() ) ret.put( root, getChildren( root ) ); else ret.put( root, root ); JTree tree = new JTree( ret ); JFrame frame = new JFrame( "memo10ex2" ); frame.getContentPane().add( tree ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.pack(); frame.setVisible( true ); } public Hashtable getChildren( File parent ) { File[] dirs = parent.listFiles(); Hashtable ret = new Hashtable(); for( int i = 0; i < dirs.length; i++ ) { if( dirs[i].isDirectory() ) ret.put( dirs[i], getChildren( dirs[i] ) ); else ret.put( dirs[i], dirs[i] ); } return ret; } }