• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

InputMap / ActionMap actions leave characters in TextArea

 
Ranch Hand
Posts: 35
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've added a JPopupMenu to a JPanel with a TextArea in it. The popup menu is attached to the TextArea with the usual MouseListener.

To bring up the popup menu with a keystroke, I've gotten the InputMap and added a (key, action) pair to it. The key is an alt P, the action is a defined Action instance.

The software works fine in popping up the menu and closing the menu. Alas, if the focus is on the text area, alt p ALSO produces a "pi" symbol in the text area.

The Action class uses an ActionEvent that doesn't have a consume() method. What sort of action for the ActionMap should I be using so that I can consume the alt P?


Thanks,

Chris

Here's a snippet :


 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't want the default action of the keystroke to affect the text area, remove that mapping from the appropriate input map of the text area.
 
reply
    Bookmark Topic Watch Topic
  • New Topic