JTree中的问题
初学java,照着资料做了一个JTree但是子节点名称前面多了上一级节点的名称,拜托哪位高手帮帮忙
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.filechooser.FileSystemView;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.io.*;
public class MyTree {
public MyTree() {
CreateTree frame=new CreateTree();
frame.setSize(400,320);
frame.setTitle( "MyTree ");
frame.setVisible(true); //设置窗体为可见
frame.setResizable(false);//设置窗体不可调整大小
}
public static void main(String[]args){
new MyTree();
}
}
class CreateTree extends JFrame{
JPanel pane1;
JPanel pane2;
JTree tree;
JScrollPane scroll;
JTextArea area;
JPopupMenu popupMenu;
JMenuItem copy,cut,paste;
public CreateTree(){
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
JbInit();
}
public void JbInit(){
pane1=(JPanel)getContentPane();
pane1.setLayout(new GridLayout(1,2));