How to set focus on TextBox in GWT Popup Panel?
Question
I want to set focus on textbox in popup panel. I have Login popup panel which contains textbox for username and password, So How can I set focus on username when popup loads/showed? I am using GWT/Java.
thanks
Solution
After you call .show() on your popup panel, use this:
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
myTextField.setFocus();
}
});
OTHER TIPS
Do you mean TextBox? There is no TextField in the standard GWT library.
textField.setFocus(true);
Possible duplicate, this thread might answer your question: not able to set focus on TextBox in a GWT app
If you init your field you can use
textField.setFocus(true);
but more preferable this way
FocusSetter.setFocus(textFocus, true);
because you should not control is field initialize or not
try this
textField.requestFocusInWindow();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow