以下是我的程序,系统提示我在定义节点对象时出错,请问我问题处在什么地方,该怎么改正,请高手指点
package jbuilder中tree的使用;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTree;
import java.awt.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Frame1 extends JFrame {
JPanel contentPane;
JTree jTree1 = new JTree();
public Frame1() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(400, 300));
setTitle("Jbuilder中JTree的使用");
//创建根节点
DefaultMutableTreeNode root=new DefaultMutableTreeNode("JComponent");
//创建枝节点plant1
//DefaultMutableTreeNode plant1=new DefaultMutableTreeNode("JMenuBar");
root.add(plant1);
//创建枝节点plant2
DefaultMutableTreeNode plant2=new DefaultMutableTreeNode("JPopupMenu");
root.add(plant2);
//创建枝节点plant3
DefaultMutableTreeNode plant3=new DefaultMutableTreeNode("AbstractButton");
root.add(plant3);
//创建下一层枝节点plantSon
DefaultMutableTreeNode plantSon=new DefaultMutableTreeNode("JMenuItem");
plant3.add(plantSon);
//创建叶节点laef1
DefaultMutableTreeNode laef1=new DefaultMutableTreeNode("JMenu");
plantSon.add(laef1);
//创建叶节点laef2
DefaultMutableTreeNode laef2=new DefaultMutableTreeNode("JCheckBoxMenuItem");
plantSon.add(laef2);
//创建叶节点laef3
DefaultMutableTreeNode laef3=new DefaultMutableTreeNode("JRadioButtonMenuItem");
plantSon.add(laef3);
jTree1=new JTree(root);
jTree1.setBounds(new Rectangle(21, 11, 175, 185));
jTree1.addTreeSelectionListener(new Frame1_jTree1_treeSelectionAdapter(this));
contentPane.add(jTree1);
}
public void jTree1_valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node=(DefaultMutableTreeNode)jTree1.getLastSelectedPathComponent();
}
}
class Frame1_jTree1_treeSelectionAdapter implements TreeSelectionListener {
private Frame1 adaptee;
Frame1_jTree1_treeSelectionAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void valueChanged(TreeSelectionEvent e) {
adaptee.jTree1_valueChanged(e);
}
}