From a57f70ee4ae1f9953e90e647bd1aa98328d9e4b9 Mon Sep 17 00:00:00 2001 From: lawrencekoehler Date: Sun, 12 Nov 2023 16:03:20 +0100 Subject: [PATCH] Added TODO 4 in Task 1 --- .../com/example/esde/views/task1/Task1.java | 21 ++++++++++++++++++- .../com/example/esde/views/task1/Task1.java | 8 +++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/vaadin-app/src/main/java/com/example/esde/views/task1/Task1.java b/vaadin-app/src/main/java/com/example/esde/views/task1/Task1.java index 7166364..a9cd47b 100644 --- a/vaadin-app/src/main/java/com/example/esde/views/task1/Task1.java +++ b/vaadin-app/src/main/java/com/example/esde/views/task1/Task1.java @@ -1,7 +1,9 @@ package com.example.esde.views.task1; import com.example.esde.views.MainLayout; +import com.example.esde.views.task2.Task2; import com.vaadin.flow.component.button.Button; +import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.html.H2; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.textfield.TextField; @@ -20,13 +22,15 @@ public class Task1 extends VerticalLayout { private H2 header; private TextField textfield; private Button button; + private Button successButton; public Task1() { header = createHeader(); button = createButton(); + successButton = createSuccessButton(); textfield = null; - add(header, button); + add(header, button, successButton); } /** @@ -57,4 +61,19 @@ private Button createButton() { return button; } + /** + * TODO 4.1: Add a method that returns a new green button (hint: change the property "background-color") + * TODO 4.2: Clicking on the button should navigate to the next task (Task2) + * (Dont forget to add the button to the layout) + */ + private Button createSuccessButton() { + Button button = new Button(); + button.setText("Next Task"); + button.getStyle().set("background-color","green"); + button.addClickListener(buttonClickEvent -> { + getUI().ifPresent(ui -> ui.navigate(Task2.class)); + }); + return button; + } + } diff --git a/vaadin-demo/src/main/java/com/example/esde/views/task1/Task1.java b/vaadin-demo/src/main/java/com/example/esde/views/task1/Task1.java index 5397052..e5623b8 100644 --- a/vaadin-demo/src/main/java/com/example/esde/views/task1/Task1.java +++ b/vaadin-demo/src/main/java/com/example/esde/views/task1/Task1.java @@ -7,8 +7,6 @@ import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.Route; -import com.vaadin.flow.theme.Theme; -import com.vaadin.flow.theme.lumo.Lumo; /** * This will be a very simple task, change some values, create some objects, and you'll be done! @@ -57,4 +55,10 @@ private Button createButton() { return button; } + /** + * TODO 4.1: Add a method that returns a new green button (hint: change the property "background-color") + * TODO 4.2: Clicking on the button should navigate to the next task (Task2) + * (Dont forget to add the button to the layout) + */ + }