Adel Boutros
Adel Boutros

Reputation: 10285

Find the TreeNode at a certain Point

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

How can I get the DefaultMutableTreeNode right-clicked?

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

Can you please help me?

Upvotes: 4

Views: 1488

Answers (1)

Robin
Robin

Reputation: 36601

Use the JTree#getClosestPathForLocation method

Upvotes: 3

Related Questions