Refactored DayPane;

This commit is contained in:
Marc Beyer 2022-01-31 21:16:01 +01:00
parent 31dbeec55a
commit d980edeaad
2 changed files with 27 additions and 30 deletions

View File

@ -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();

View File

@ -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;
}
}