posted 22 years ago
Hello,
I am having a problem with Key Listeners. I have an application that has a JTabbedPane. On 1 page I have several JButtons with Key Listeners attached to them. I detect if the enter key has been struck, If so I execute some code. On the second page I have a JList with a Key Listener attached, If a user hilights a selection and presses enter, some code gets executed.
Here is the problem. I am tabbing throught the app with the tab key. When I get to the list and the list has focus and is hi-lighted, So does a JButton on the first page, when I hit the enter key on the list, the proper code gets executed, but then somehow the Key Listener for the Jbutton on the first page get fired and that code executes. I am not even on that page. Why does the code get executed ! I can put a ugly work around and check to make sure the user is on the page and only execute the code if the page is selected, but I would like a more elegant solution.
Any thoughts would be much appreciated.
Thanks,
John Palmieri