aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes DefaultMutableTreeNode cannot regain focus on the second click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "DefaultMutableTreeNode cannot regain focus on the second click" Watch "DefaultMutableTreeNode cannot regain focus on the second click" New topic
Author

DefaultMutableTreeNode cannot regain focus on the second click

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 580
I have an application that has a JTree, there are a couple of DefaultMutableTreeNode's in there
When a node is selected, a JDialog is dispatched. After the JDialog is disposed,
I click on the same item again. But the same JDialog
doesn't reappear again. I have to choose another item and click back
on that one in order to dispatch the same JDialog again and so on so forth.

I know there is got to be something to do with

But just don't know how


K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1966
    
    7

Then maybe disposing it is not the right approach. Try hiding it.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 580
K. Tsang wrote:Then maybe disposing it is not the right approach. Try hiding it.


No, it doesn't do the trick.
The problem I am having is When I click it the second time,
there is no response to that click.
The program stays as it is.
Thanks
Jack
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

I click on the same item again. But the same JDialog
doesn't reappear again.

Thats because the selection doesn't change.
Solution: Clear the selection (search the API docs for methods which will let you do this) after you display the dialog


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 580
Maneesh Godbole wrote:
I click on the same item again. But the same JDialog
doesn't reappear again.

Thats because the selection doesn't change.
Solution: Clear the selection (search the API docs for methods which will let you do this) after you display the dialog


Oh, tree.ClearSelection, as simple as this. Thanks
Jack
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

Yes. Most of the stuff is already in place. As a developer, it is always a good idea to refer to the API docs when you are stuck on something.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DefaultMutableTreeNode cannot regain focus on the second click
 
Similar Threads
Problem displaying JScrollPane with custom gradient paint
JTree expansion
JTree
Why the centerPanel won't refresh automatically?
JTree not updating