请教关于树的问题
比如写了有关树的结构:import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Tree{
public Tree(){
JFrame f=new JFrame("TreeText");
Container contentPane=f.getContentPane();
String[] s1={"1","2","3"};
String[] s2={"4","5"};
String[] s3={"6","7","8"};
Hashtable hashtable1=new Hashtable();
Hashtable hashtable2=new Hashtable();
hashtable1.put("A",s1);
hashtable1.put("B",s2);
hashtable1.put("C",hashtable2);
hashtable2.put("D",s3);
/**定义widnows界面**/
JTree tree=new JTree(hashtable1);
JScrollPane scrollPane=new JScrollPane();
scrollPane.setViewportView(tree);
contentPane.add(scrollPane);
f.pack();
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main(String[] args){
new Tree();
}
}
想通过选择树的节点打开一个文件,并将文件的内容显示在一个文本框里!可否告诉我有关代码?非常感谢!
----------------解决方案--------------------------------------------------------
http://java.sun.com/docs/books/tutorial/uiswing/components/tree
see this link above.
----------------解决方案--------------------------------------------------------
非常感谢!
----------------解决方案--------------------------------------------------------
这个还真不明白
----------------解决方案--------------------------------------------------------