I have following handler

textArea.addKeyDownHandler(new KeyDownHandler() {
            @Override
            public void onKeyDown(KeyDownEvent event) {
                //here
            }
        });

I need to enable save button with id "idsave", but I am not able to refer the button. I am new to GWT, any help would be appreciated.

有帮助吗?

解决方案 2

If you don't have the reference of the button then try with the id.

// get element by id
Element saveButtonElement = RootPanel.get("idsave").getElement(); 

// remove disabled attribute to make it enable
saveButtonElement.removeAttribute("disabled"); 

其他提示

Typically, you do not use element ids in GWT. If you created a button, you can simply use it:

private Button saveButton;
...

saveButton = new Button("Save");
textArea.addKeyDownHandler(new KeyDownHandler() {
     @Override
     public void onKeyDown(KeyDownEvent event) {
          saveButton.setEnabled(true);
     }
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top