You can add focusListener and blurListener for each component. If the component has focus, you set the object for the current component, if the blurListener receives the call, you set it to zero.
If the object is! = Null, you just need to check which component it is, and you know which one has focus.
source share