This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a program using one Jlist where if I select the value using the mouse then the related values to the selected item are displayed in another Jlist on the form. This works fine but I noticed that I also need to handle thsi when the up-down keyboard keys are pressed.. I then implemented KeyListener as well as ListSelectionListener with all the required methods and I'm checking up KeyEvent up down etc..and in the keyPressed methods I want to place the same code as in the valueSelected method belonging to the ListSelectionListener interface but it does not have the required effect. before I post my code, can someone advise if I'm doing the right thing or can it be handled a better way?
In case anyone else wants to know, I added to separated event handlers to my JList. One for KeyListener and another for ListSelectionListener. I then had a class implementing both these interfaces with the code I wanted to fire in the keyPressed and keyReleased methods(implemented as part of the KeyListener interface) and the same code in the valueChanged method belonging to the ListSelectionListener Interface.