I would like to use a custom icon from a picture file in Vaadin 10.
Up to Vaadin 8 it was possibleto load the icon file via ExternalResource:
public final static Resource MY_ICON = new ExternalResource("VAADIN/images/my_icon.png");
and then just use the resource as icon:
Button button = new Button("My Button text");
button.setIcon(MY_ICON);
The setIcon method in Vaadin 10 requires a Component as parameter. How can i load my Icon into a Component? Is there some out of the box solution in vaadin 10?
I would prefer a solution with pure java like in vaadin 7/8.
I will post also my own solution since its specific for Button Icon Styling. You have to load the icon file into a vaadin Image (com.vaadin.flow.component.html.Image) first. but it also requires some additional styling to position the icon correctly in the button.
usage: