Button 按钮,在前面Vaadin Web应用开发教程(5):Vaadin Web应用的基本组成部分 中介绍事件处理时已经对Button的用法做了说明。当用户点击按钮时会触发Button.ClickEvent ,可以使用 Button.ClickListener 来侦听这个事件。
- public class TheButton extends CustomComponent
- implements Button.ClickListener {
- Button thebutton;
- public TheButton() {
- // Create a Button with the given caption.
- thebutton = new Button ("Do not push this button");
- // Listen for ClickEvents.
- thebutton.addListener(this);
- setCompositionRoot(thebutton);
- }
- /** Handle click events for the button. */
- public void buttonClick (Button.ClickEvent event) {
- thebutton.setCaption ("Do not push this button again");
- }}