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 ActionListener - event is a tab? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ActionListener - event is a tab?" Watch "ActionListener - event is a tab?" New topic
Author

ActionListener - event is a tab?

John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
My documentation refers only to the "Return" as an event which will trigger the ActionListener (for a JTextField). Can it work so that either a Tab or a Return event will trigger the ActionListener?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Well, sort of.

If you actually have you code in an Action class then have your "ActionLister" call the Action instead, then you can also add a FocusListener, which is needed to capture if the user has left the TextField, can also call the Action too, therefore reusing the Action class and not having duplicate Code.

You can also implement a KeyListener for getting which key is pressed, but I think the functionality you are looking for with Return and Tab is best implemented in the FocusListener instead, maybe.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
Thank you, I was looking for how to do this as well...ain't searches great!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionListener - event is a tab?