File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Is it possible to do this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Is it possible to do this" Watch "Is it possible to do this" New topic

Is it possible to do this

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I have several JTextfields which need to be populated.These
amounts in the end need to be calculated, the way I have things now the user needs to press enter at the end of filling each field; Is there some way to listen to when the user has left one textfield and gone on to the next.
thanks 4 all your time
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Yes... look into the FocusListener class... it supports the focusLost(FocusEvent) and focusGained(FocusEvent) methods. You will be interested in focusLost(). Just add a FocusListener to each textfield, and you'll be ready to go. It gets launched whenever the user does something to get out of the textfield( i.e. clicks on another field with the mouse or tabs out of it ).


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Is it possible to do this
It's not a secret anymore!