aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to identify which control get focus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to identify which control get focus" Watch "how to identify which control get focus" New topic
Author

how to identify which control get focus

mani senthil
Greenhorn

Joined: Jan 18, 2007
Posts: 17
suppose there are two textbox and we want to find which textbox has got foucus currently?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
there are a number of ways

check the textfields to see if either currently has the focus
if(textField1.isFocusOwner())...
else if(textField2.isFocusOwner())...

check the focusManager to get the focused component,
Component currentFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

add focusListeners, and set flags when focused
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to identify which control get focus
 
Similar Threads
Special List box
Textbox value removal
Passing Parameters through JSP
How to read contents of a different Textbox's on a Tab in a TabPanel
to get value from text box using javascript