Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Which textbox has focus

Hai
I have a class say a() .That class is adding 3 jtextfields. I am calling this class in an japplet class. I want to check which textbox has focus .I used textbox1.hasFocus().But it is not working. Is there is any way to know whether a textbox has focus.I have to use java code. The funcation hasFocus() is working in FocusGained event. But I want it in one funcation . Can anyone tell me what to do. I wrote code as

<code>
public int abc() {
int result = 0;
if(text1.hasFocus()){
result = 1;
}
else if(text2.hasFocus()){

result =2;
}
return result;
}
</code>
[640 byte] By [daina] at [2007-11-11 7:21:13]