my dog learned polymorphism
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 Java Interview Guide this week in the Jobs Discussion 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
I agree. Here's the link:
subject: Focuse object
It's not a secret anymore!