Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Popupmenus staying popped up

 
Joe Lemmer
Ranch Hand
Posts: 171
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic