Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2007

Tip: Looking for answers? Try searching our database.

Listeners Firing Too Often

Thread view: 
Jason Cavett - 22 Feb 2007 21:07 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
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.