• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Popupmenus staying popped up

Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I have a JTextArea that is registered with a KeyListener class.

My class that implements the KeyListener class has code that checks to see what letter has just been typed into the JTextArea. Certain letters result in the calling of a method which I've called popupAction.

The popupAction method produces a popupmenu displaying accented characters to appear by the JTextField. My idea is that I can click on one of the letters displayed in the popup menu if I want to change the last letter typed to one of the accented ones on the list.

I've managed to implement the above finally. BUT, if I don't want to choose one of the accented letters on the list, I want to just be able to carry on typing with the popupmenu disappearing as soon as I type the next letter.

It is not doing this. It's just staying there until I choose a letter from the list or until I use my mouse to reset the focus at the end of the text in the textfield.

I thought perhaps there might be a method still running on the stack which is "getting in the way" or something like that, but the popupAction method ends once it has created the menu and the actionperformed method in my keylistener class ends after the invoking of the popup action method, so the textfield should still be listening for more keystrokes.

Can anyone shed some light on the problem? How can I make the popup menu disappear just by continuing typing?

Many thanks

Joe Lemmer
    Bookmark Topic Watch Topic
  • New Topic