Dynamic icon for a button...

How to make the icon for a button dynamic?

After I click the button. It should use another icon.

The simplest way would be just changing the icon in the buttonClick method of the ClickListener. E.g. like the following.

final Button myButton = new Button (“A bug”);
myButton.setIcons(VaadinIcons.BUG);
myButton.addClickListener(new Button.ClickListner() {
public void buttonClick(ClickEvent e) {
myButton.setIcon(VaadinIcons.BUG_O);
}
}