tags:

views:

35

answers:

1

Hi Everyone, I am using a JTree and in this to raname a JTree node I am using right click(Rename through popup) or F2 key or double click. But problem is : when I rename a name and hit Enter key, node successfully renamed and when I rename a name and click anywhere on the frame(windows explorer style), node name does not rename.

Please give me a solution for this problem and Thanks in advance.

A: 

The ability to save the current edit by clicking elsewhere in the tree is not something that comes standard as part of the default JTree implementation. You're going to have to get into the details of how to use trees and do some special customization in order to achieve this functionality. This sounds like it would involve something with the focus of Swing components, i.e., when the tree gains focus, if the node is being edited, then save the node rename.

Shakedown
Could you please tell me which method is called at the time of pressing Enter key after editing a tree node.......
Could you please tell me which method is called at the time of pressing Enter key after editing a tree node.......otherwise could you explain your suggestion in detail
Thanks for your response
You can add a `FocusListener` on your tree cell editor. The Enter key is bound by the cell editor.
Geoffrey Zheng