File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Popupmenus staying popped up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Popupmenus staying popped up" Watch "Popupmenus staying popped up" New topic
Author

Popupmenus staying popped up

Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
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


OCPJP 85%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Popupmenus staying popped up