DefaultMutableTreeNode fatherNode; void jTree2_mouseClicked(MouseEvent e) {
if(jTree2.getPathForLocation(e.getX(),e.getY())!=null){
fatherNode=(DefaultMutableTreeNode)jTree2.getPathForLocation(e.getX(),e.getY()).getLastPathComponent();
}//end of if !null
}///////////////end of void
void jButton1_actionPerformed(ActionEvent e) {
DefaultMutableTreeNode newNode=new DefaultMutableTreeNode("new node");
fatherNode.add(newNode);
jTree2.UpdateUI();
}
if(jTree2.getPathForLocation(e.getX(),e.getY())!=null){
fatherNode=(DefaultMutableTreeNode)jTree2.getPathForLocation(e.getX(),e.getY()).getLastPathComponent();
}//end of if !null
}///////////////end of void
void jButton1_actionPerformed(ActionEvent e) {
DefaultMutableTreeNode newNode=new DefaultMutableTreeNode("new node");
fatherNode.add(newNode);
jTree2.UpdateUI();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货