From ce09d318e05429f9e56c69884a0458c8a63d59be Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Sun, 2 Apr 2017 14:26:56 +0200 Subject: [PATCH] Fixed #62 - add button "today" on date toggler --- src/de/deadlocker8/budgetmaster/ui/Controller.java | 13 +++++++++++++ src/de/deadlocker8/budgetmaster/ui/GUI.fxml | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/de/deadlocker8/budgetmaster/ui/Controller.java b/src/de/deadlocker8/budgetmaster/ui/Controller.java index 72dd89028..c6b59b2e8 100644 --- a/src/de/deadlocker8/budgetmaster/ui/Controller.java +++ b/src/de/deadlocker8/budgetmaster/ui/Controller.java @@ -43,6 +43,7 @@ public class Controller implements Refreshable @FXML private Label labelMonth; @FXML private Button buttonLeft; @FXML private Button buttonRight; + @FXML private Button buttonToday; @FXML private TabPane tabPane; @FXML private Tab tabHome; @FXML private Tab tabPayments; @@ -124,6 +125,9 @@ public class Controller implements Refreshable FontIcon iconNext = new FontIcon(FontIconType.CHEVRON_RIGHT); iconNext.setSize(20); buttonRight.setGraphic(iconNext); + FontIcon iconToday = new FontIcon(FontIconType.CALENDAR_ALT); + iconToday.setSize(20); + buttonToday.setGraphic(iconToday); // apply theme anchorPaneMain.setStyle("-fx-background-color: #DDDDDD"); @@ -131,6 +135,7 @@ public class Controller implements Refreshable labelNotification.setStyle("-fx-text-fill: #FFFFFF; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-color: transparent;"); buttonLeft.setStyle("-fx-background-color: transparent;"); buttonRight.setStyle("-fx-background-color: transparent;"); + buttonToday.setStyle("-fx-background-color: transparent;"); if(settings == null) { @@ -206,6 +211,14 @@ public class Controller implements Refreshable refresh(); } + + public void today() + { + currentDate = DateTime.now(); + labelMonth.setText(currentDate.toString("MMMM yyyy")); + + refresh(); + } public DateTime getCurrentDate() { diff --git a/src/de/deadlocker8/budgetmaster/ui/GUI.fxml b/src/de/deadlocker8/budgetmaster/ui/GUI.fxml index 4e15a8e75..122b897e5 100644 --- a/src/de/deadlocker8/budgetmaster/ui/GUI.fxml +++ b/src/de/deadlocker8/budgetmaster/ui/GUI.fxml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.geometry.Insets?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <?import javafx.scene.control.Tab?> @@ -23,6 +24,11 @@ </font> </Label> <Button fx:id="buttonRight" mnemonicParsing="false" onAction="#nextMonth" /> + <Button fx:id="buttonToday" alignment="CENTER" mnemonicParsing="false" onAction="#today"> + <HBox.margin> + <Insets /> + </HBox.margin> + </Button> </children> </HBox> <StackPane alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS"> -- GitLab