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.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
How to change Button icon and text by dynamically?
My code not working:
Button btnSearch = new Button("Apply filter");
btnSearch.setIcon(FontAwesome.SEARCH);
btnSearch.addClickListener(e->{
e.getButton().setIcon(FontAwersome.CANCEL)
e.getButton().setCaption("Cancel filter");
});
Last updated on
This should work. Please see that you are not doing something else in the rest of the code that is affecting this.
Last updated on
Роман Последовский: My code not working:
Button btnSearch = new Button("Apply filter"); btnSearch.setIcon(FontAwesome.SEARCH); btnSearch.addClickListener(e->{ e.getButton().setIcon(FontAwersome.CANCEL) e.getButton().setCaption("Cancel filter"); });
Maybe it's simple misspelled? :)
Try e.getButton().setIcon(FontAwesome.CANCEL)instead.
Last updated on
You cannot reply to this thread.