I am developing a GUI (in Java, of course) that has a JTree on the
left hand side of the window (similar to Windows Explorer or something
like that) and on the right hand side the user can open various
property windows to edit the items in the JTree.
The issue I'm having is this...
I have added a key listener to one of the property windows so that,
when the user hits the delete key, they can delete parts of the
equation they constructed (mathematical equations). The JTree also
has a separate key listener that will delete the selected nodes in the
tree if I hit the delete key. Both these keylisteners work fine on
their own.
However, when I open up the property window and highlight part of the
equation and hit the delete key, not only does that part of the
equation delete, but then the JTree also captures the KeyAction and
deletes the currently selected node in the JTree.
I have no clue why this is happening. The JTree doesn't have direct
focus. I haven't been able to find any real connection between the
two components.
Any ideas/suggestions/?
Andrew Thompson - 22 Feb 2007 21:46 GMT
> I am developing a GUI (in Java, of course)
...
> Any ideas/suggestions/?
Supply an SSCCE.
Andrew T.
Jason Cavett - 23 Feb 2007 15:58 GMT
> I am developing a GUI (in Java, of course) that has a JTree on the
> left hand side of the window (similar to Windows Explorer or something
[quoted text clipped - 20 lines]
>
> Any ideas/suggestions/?
Solution:
Both listeners worked fine on their own. The issue was that the main
menu bar used the VK_DELETE accelerator for it's Delete menu option.
So, when the user pressed "Delete" on the keyboard, the menu bar fired
"deletes" to ALL components in the GUI.
I updated the GUI so that when the user hits the Delete key, delete is
only fired on the component that currently has focus.