Autofocus of first editable field in layout

I want that after loading application’s layout, a first editable field in it become focused.
It seems that calling ((Focusable) component).focus() in init() method of UI is a wrong idea.
What are the other possibilities?

Got an answer from the other forum: the solution is to move ((Focusable) component).focus() inside acces(new Runable(){}) atthe end of UI.init() method:

@Override
protected void init(VaadinRequest request) {
//

access(new Runnable() {
@Override
public void run() {
((Focusable) component).focus();
}
});
}

Seems like Vaadin bug, since result of method call depends on the execution context and yhis is not clearly stated in the documentation.