如何查找JTree节点,并展开它
1个回答
展开全部
<pre t="code" l="java">putree.addMouseListener(new MouseAdapter() { // 添加鼠标事件处理
@Override
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) { // 点击了鼠标左键
TreePath path = tree.getSelectionPath();
if(path != null) tree.expandPath(path);// 展开节点
} // End if
} // End mousePressed function
});
@Override
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) { // 点击了鼠标左键
TreePath path = tree.getSelectionPath();
if(path != null) tree.expandPath(path);// 展开节点
} // End if
} // End mousePressed function
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询