Skip to content

Commit a766e46

Browse files
scardanzanjavier-godoy
authored andcommitted
fix(demo): fix invalid input parsing error on text field
1 parent 6e52645 commit a766e46

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/test/java/com/flowingcode/vaadin/addons/simpletimer/SimpletimerDemo.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ public SimpletimerDemo() {
5151
timer.getStyle().set("font-size", "40px");
5252
timer.setStartTime(60);
5353

54-
Span timerTitle = new Span("Simple Count Up Timer");
54+
final Span timerTitle = new Span("Simple Count Up Timer");
5555

5656
final TextField startTime =
5757
new TextField("Start Time", e -> {
58-
time = new BigDecimal(e.getValue());
59-
update();
58+
try {
59+
time = new BigDecimal(e.getValue());
60+
update();
61+
} catch (final Exception ex) {
62+
Notification.show("Please enter a number");
63+
}
6064
});
6165
final Checkbox countUp = new Checkbox("Count Up", false);
6266
countUp.addValueChangeListener(
@@ -111,7 +115,7 @@ public SimpletimerDemo() {
111115
final HorizontalLayout topLayout = new HorizontalLayout(timerTitle, timer);
112116
topLayout.setAlignItems(Alignment.CENTER);
113117

114-
HorizontalLayout options =
118+
final HorizontalLayout options =
115119
new HorizontalLayout(countUp, fractions, minutes, hours, visible, doubleDigitHours);
116120
options.setAlignItems(Alignment.CENTER);
117121
options.getStyle().set("flex-wrap", "wrap");

0 commit comments

Comments
 (0)