• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Eventlistner

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I've created a applet with implements MouselListener interface. I the appplet I use to display all the names of my customers. On the click event of the mouse on a particular user, I use to display the information about that user on the side of the applet. It is working fine.
Now as a enhancement i want a new feature. I want the application user should be able to navigate through the users in the applets , with the helps of arrow keys of the keboard, also.
this can be achieved by implementing KeyListner interface which contains the following methods:
keyPressed
keyReleased
keyTyped
But i just want to trap the event , when arrow keys are pressed. But how can I do this specifically for arrowkeys.
can anybody pl help me.
Thanks in advance
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What component are you using to display the names? Assigning the MouseListener to the Applet itself isn't a good design decision, and it's probably causing problems. Whatever event listener interface you choose, assign it to the lowest possible component in your containment hierarchy - the one that displays the names.
To use the KeyListener interface, you get the key code from the KeyEvent with getKeyCode() and test it against the virtual key constants of the KeyEvent class (like VK_DOWN or VK_UP) to determine what key was pressed or typed. If you're using a List component to display the names, then it already handles keyboard scrolling for you.
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic