diff --git a/client/app/src/main/java/main/MainController.java b/client/app/src/main/java/main/MainController.java index 70566b4..0f8ba7d 100644 --- a/client/app/src/main/java/main/MainController.java +++ b/client/app/src/main/java/main/MainController.java @@ -137,27 +137,30 @@ public class MainController { private void createWeek() { for (int i = 0; i < 7; i++) { - DayPane dayPane = new DayPane(dayNames[i]); + DayPane dayPane = new DayPane(); this.dayLabel[i] = dayPane.getDayLabel(); calendarGrid.add(dayPane.getDayLabel(), i, 0); dayVBoxes[i] = dayPane.getDayVBox(); - calendarGrid.add(dayPane.getScrollPane(), i, 1); + calendarGrid.add(dayPane, i, 1); } } private void addEvent(Event event) { EventPane eventPane = new EventPane(event); - eventPane.getEditBtn().setOnAction(event1 -> MainApplication.loadScene( - "Termin bearbeiten", - "edit-event.fxml", - "create-event.css", - 650, - 650, - fxmlLoader -> { - EditEventController editEventController = fxmlLoader.getController(); - editEventController.setCurrentEvent(event); - } - )); + eventPane.getEditBtn().setOnAction(event1 -> { + MainApplication.loadScene( + "Termin bearbeiten", + "edit-event.fxml", + "create-event.css", + 650, + 650, + fxmlLoader -> { + EditEventController editEventController = fxmlLoader.getController(); + editEventController.setCurrentEvent(event); + } + ); + updateEvents(); + }); eventPane.getDeleteBtn().setOnAction(e -> { DataController dataController = new DataController(); diff --git a/client/app/src/main/java/ui/DayPane.java b/client/app/src/main/java/ui/DayPane.java index d1aa3c8..26dc3e3 100644 --- a/client/app/src/main/java/ui/DayPane.java +++ b/client/app/src/main/java/ui/DayPane.java @@ -4,30 +4,28 @@ import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; import javafx.scene.layout.VBox; -public class DayPane { +public class DayPane extends ScrollPane { - private Label dayLabel; - private VBox dayVBox; - private ScrollPane scrollPane; + private final Label dayLabel; + private final VBox dayVBox; - public DayPane(String name) { + public DayPane() { dayLabel = new Label(); - dayLabel.setText(name); dayLabel.setMaxHeight(Double.MAX_VALUE); dayLabel.setMaxWidth(Double.MAX_VALUE); dayLabel.getStyleClass().add("labelDays"); - scrollPane = new ScrollPane(); - dayVBox = new VBox(); + dayVBox.getStyleClass().add("vBoxDays"); dayVBox.setSpacing(10); - scrollPane.setContent(dayVBox); - scrollPane.setFitToWidth(true); - scrollPane.setFitToHeight(true); - scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); - scrollPane.getStyleClass().add("scrollDays"); + setContent(dayVBox); + setFitToWidth(true); + setFitToHeight(true); + setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); + getStyleClass().add("scrollDays"); + getStyleClass().add("scrollDays"); } public Label getDayLabel() { @@ -37,8 +35,4 @@ public class DayPane { public VBox getDayVBox() { return dayVBox; } - - public ScrollPane getScrollPane() { - return scrollPane; - } }