Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Dynamic icon for a button...

Weiqiang Xiong
6 years ago Jun 29, 2015 10:15pm
Tatu Lund
6 years ago Jun 30, 2015 8:44am

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);
}
}