GWT如何修改ClickHandler中的按钮值 [英] GWT how can I modify the button value in the ClickHandler
本文介绍了GWT如何修改ClickHandler中的按钮值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想实现这个功能,当我点击按钮时,按钮的值会改变。但我知道我不能在clickHandler中调用按钮对象本身。所以,我怎么做到这一点?
button.addClickHandler(new ClickHandler(){$ b $ public void onClick(ClickEvent事件){
button.getButtonElement()。setValue(X);
}
});
解决方案
<2>
((Button)event.getSource())。setValue(x);
或
最终按钮btn =按钮;
然后您将能够使用btn作为处理程序内部按钮的引用。
I want to implement this function, when I click on the button, the value of the button changes. But I know I cannot call the button object itself in its clickHandler. So, How can I do this?
button.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event){
button.getButtonElement().setValue("X");
}
});
解决方案
2 ways:
((Button)event.getSource()).setValue("x");
Or
Outside the handler, use
final Button btn = button;
Then you will be able to use btn as reference to the button inside the handler .
这篇关于GWT如何修改ClickHandler中的按钮值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文