//弹出菜单的方法
public void actionPerformed(ActionEvent e)
{
//添加节点
if((JMenuItem)e.getSource() == pop.addItem)
{
this.sender = true;
//this.addNode("新建节点",currentNode,this.row+1 );
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("新建节点");
this.addNode(newNode,currentNode);
this.tree.revalidate();
}
if((JMenuItem)e.getSource() == pop.addChildItem)
{
this.sender = true;
this.addChildNode("新建节点",currentNode);
this.tree.revalidate();
}
//更改节点名
if((JMenuItem)e.getSource() == pop.changItem)
{
this.sender = true;
//对树模型进行操作,保存更改的值
tree.startEditingAtPath(this.currentTreePath);
this.tree.revalidate();
}
//删除节点
if((JMenuItem)e.getSource()== pop.delItem)
{
this.sender = true;
this.delNode(currentNode);
//通知treeMolelListener值已发生变化
this.tree.revalidate();
}
}
public void actionPerformed(ActionEvent e)
{
//添加节点
if((JMenuItem)e.getSource() == pop.addItem)
{
this.sender = true;
//this.addNode("新建节点",currentNode,this.row+1 );
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("新建节点");
this.addNode(newNode,currentNode);
this.tree.revalidate();
}
if((JMenuItem)e.getSource() == pop.addChildItem)
{
this.sender = true;
this.addChildNode("新建节点",currentNode);
this.tree.revalidate();
}
//更改节点名
if((JMenuItem)e.getSource() == pop.changItem)
{
this.sender = true;
//对树模型进行操作,保存更改的值
tree.startEditingAtPath(this.currentTreePath);
this.tree.revalidate();
}
//删除节点
if((JMenuItem)e.getSource()== pop.delItem)
{
this.sender = true;
this.delNode(currentNode);
//通知treeMolelListener值已发生变化
this.tree.revalidate();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货