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 Focuse object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Focuse object" Watch "Focuse object" New topic

Focuse object

Talha-bin -Shakir
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
i have few textfields on my frame. I want to know the textfield name which is currently focused. can someone please help me. How to know the current focused object name.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this will give you the focus owner
Component currentFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

Component has a getName(), but you would be responsible for setting the name
It is sorta covered in the JavaRanch Style Guide.
subject: Focuse object
It's not a secret anymore!