diff options
author | Stephan Knitelius <stephan@knitelius.com> | 2017-08-23 08:49:45 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-08-23 09:49:45 +0300 |
commit | 5b13a397d86a20686d0052cfdec9d39696477655 (patch) | |
tree | bc9c4185acba6879b404baa296c05b7c8fcd205b | |
parent | cfb110403b2d3c62f79dec6d38bc6f131a5bd894 (diff) | |
download | vaadin-framework-5b13a397d86a20686d0052cfdec9d39696477655.tar.gz vaadin-framework-5b13a397d86a20686d0052cfdec9d39696477655.zip |
Button icon constructor (#9857)
Added utility constructor for Button(Icon, ClickActionListener):
new Button(VaadinIcons.AIRPLANE, e -> { ... });
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Button.java | 14 | ||||
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java | 5 |
2 files changed, 16 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Button.java b/server/src/main/java/com/vaadin/ui/Button.java index bb1f544622..e768831e33 100644 --- a/server/src/main/java/com/vaadin/ui/Button.java +++ b/server/src/main/java/com/vaadin/ui/Button.java @@ -124,6 +124,20 @@ public class Button extends AbstractFocusable } /** + * Creates a new push button with a click listener. + * + * @param icon + * the Button icon. + * @param listener + * the Button click listener. + * @since 8.2 + */ + public Button(Resource icon, ClickListener listener) { + setIcon(icon); + addClickListener(listener); + } + + /** * Click event. This event is thrown, when the button is clicked. * * @author Vaadin Ltd. diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java index 4f95aff06f..05033d9491 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java @@ -261,7 +261,7 @@ public class CommonParts extends VerticalLayout implements View { delay.setValue("1000"); group.addComponent(delay); - Button clear = new Button(null, new ClickListener() { + Button clear = new Button("", new ClickListener() { @Override public void buttonClick(ClickEvent event) { delay.setValue(""); @@ -329,14 +329,13 @@ public class CommonParts extends VerticalLayout implements View { pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); - pos = new Button("", new ClickListener() { + pos = new Button(ValoTheme.BUTTON_SMALL, new ClickListener() { @Override public void buttonClick(ClickEvent event) { notification.setPosition(Position.MIDDLE_RIGHT); notification.show(Page.getCurrent()); } }); - pos.addStyleName(ValoTheme.BUTTON_SMALL); grid.addComponent(pos); pos = new Button("", new ClickListener() { |