not able to set focus on TextBox in a GWT app

后端 未结 4 1181
别跟我提以往
别跟我提以往 2021-02-02 10:53

This should not be causing me so much pain but it is. It is a very weird problem. In a GWT application, I have two .java files, login.java and application.java. In login.java, I

4条回答
  •  太阳男子
    2021-02-02 11:21

    Try using Scheduler.scheduleDeferred():

    public void onModuleLoad() {
        Login login = new Login();
        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand () {
            public void execute () {
                login.textBoxUsername.setFocus(true);
            }
        });
        RootLayoutPanel.get().add(login);       
    }
    

    Update: answer updated to use Scheduler.get().scheduleDeferred() instead of DeferredCommand, which is deprecated.

提交回复
热议问题