在某个点找到TreeNode

时间:2021-04-20 12:33:38

I have a JTree with a MouseListener for Right-click detection. When the user clicks, I get a MouseEvent containing the source, the Jtree.

我有一个带有MouseListener的JTree用于右键单击检测。当用户点击时,我得到一个包含源Jtree的MouseEvent。

How can I get the DefaultMutableTreeNode right-clicked?

如何右键单击DefaultMutableTreeNode?

I thought about getting the Node at the Point presented in mouseEvent.getLocationOnScreen() but I don't know how

我想到在mouseEvent.getLocationOnScreen()中提供的Point处获取Node但我不知道如何

Can you please help me?

你能帮我么?

1 个解决方案

#1


3  

Use the JTree#getClosestPathForLocation method

使用JTree#getClosestPathForLocation方法

#1


3  

Use the JTree#getClosestPathForLocation method

使用JTree#getClosestPathForLocation方法