From c5d04a82eff15669b9d04dc0d2bb0e113ec8ca0f Mon Sep 17 00:00:00 2001 From: Leonardo Scardanzan Date: Wed, 28 Aug 2024 16:59:21 -0300 Subject: [PATCH] fix(demo): fix invalid input parsing error on text field --- .../vaadin/addons/simpletimer/SimpletimerDemo.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/flowingcode/vaadin/addons/simpletimer/SimpletimerDemo.java b/src/test/java/com/flowingcode/vaadin/addons/simpletimer/SimpletimerDemo.java index 6ca9a14..adb133a 100644 --- a/src/test/java/com/flowingcode/vaadin/addons/simpletimer/SimpletimerDemo.java +++ b/src/test/java/com/flowingcode/vaadin/addons/simpletimer/SimpletimerDemo.java @@ -51,12 +51,16 @@ public SimpletimerDemo() { timer.getStyle().set("font-size", "40px"); timer.setStartTime(60); - Span timerTitle = new Span("Simple Count Up Timer"); + final Span timerTitle = new Span("Simple Count Up Timer"); final TextField startTime = new TextField("Start Time", e -> { - time = new BigDecimal(e.getValue()); - update(); + try { + time = new BigDecimal(e.getValue()); + update(); + } catch (final Exception ex) { + Notification.show("Please enter a number"); + } }); final Checkbox countUp = new Checkbox("Count Up", false); countUp.addValueChangeListener( @@ -111,7 +115,7 @@ public SimpletimerDemo() { final HorizontalLayout topLayout = new HorizontalLayout(timerTitle, timer); topLayout.setAlignItems(Alignment.CENTER); - HorizontalLayout options = + final HorizontalLayout options = new HorizontalLayout(countUp, fractions, minutes, hours, visible, doubleDigitHours); options.setAlignItems(Alignment.CENTER); options.getStyle().set("flex-wrap", "wrap");