Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
how to focus components inside a sub-window
I have a sub-window which contains a textfield. when i open the sub-window i need the focus to be in the textfield and all the text should be seleced.
i use the textfield.focus() and textfield.selectAll() method to achieve this.
But in the UI i don't the textfield focued or all text selected.
i have focus and blur listeners added to the textfield where i just do a SOP. and i could see the SOPs.
am i missing out something?
Could you give some sample code on how you are setting the focus to the sub-window TextField on opening the window?
I tested setting the focus and selecting all in field both with:
field.focus();
field.selectAll();
UI.getCurrent().addWindow(w);
and
UI.getCurrent().addWindow(w);
field.focus();
field.selectAll();
both ways focused the text field and selected all the text in the sub-window so I could just start typing in new text over the old one.