How to use double-click to make JTree nodes editable

I'm having some difficulties making my JTree component work as I prefer. I have created a JTree with nodes consisting of four Jlabel components. When the user double-clicks on a node, I want it to become editable. My problem is that by default a node in a JTree is editable when a user clicks the node just once. This makes it imipossible to select a node without making it editable. Does anyone know any good way to handle this, so the nodes in the tree only is editable when the user double-clicks it. I am looking for something similar like the method SetToggleClickCount(), but havent found anything that works the way I prefer so far.

Please help me, I have spent way too much time trying to solve this!!

Thanks in advance,

Who is Participating?
Giant2Connect With a Mentor Commented:
Do you have seen here?

You must build your own selectionModel.

Bye, Giant.
hoomanvConnect With a Mentor Commented:
listen to mouse events and on double click occurence, use this method to start editing a node

 void startEditingAtPath(TreePath path)
          Selects the node identified by the specified path and initiates editing.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

link allready posted (sun book)
sorry Giant2
i opened and i copy it by mistake
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.