Mark
Mark

Reputation: 29129

Why is the text not selected or editable when I triple click a JTree node?

I have a JTree that I have configured to be editable. When I triple click on the node to edit the underlying text field, it is drawn but the text is not selected and is not editable. The only way I can edit the node successfully is to navigate to another application and then back to the Java frame. It is as if when first trying to edit the text field is not receiving focus properly.

Does anyone know why I might be seeing this behaviour? The JTree has drag and drop enabled and also a MouseListener added to handle popup menus. Could these conflict with editing/focus somehow?

I am running on Fedora 14 using the latest Java 6u25 JDK.

Upvotes: 1

Views: 295

Answers (2)

Mark
Mark

Reputation: 29129

I found the cause of the problem.

My application has a login frame that is hidden when the main frame is opened. A bug in the login frame meant that a text field was stealing the focus even though the frame had been hidden. This then caused problems with the text field on the JTree getting the focus on edit.

Upvotes: 0

camickr
camickr

Reputation: 324128

The JTree has drag and drop enabled and also a MouseListener added to handle popup menus. Could these conflict with editing/focus somehow?

Remove that code and see what happens!

That is the point of creating a SSCCE. Start with basic code from the JDK to see how it works. Then, assuming it is working you add your custom code. When it stops working, you've isolated where the problem is and then maybe we can help.

Upvotes: 1

Related Questions