From e22cb0b24d3745d988b2f6fcd80e84b40ff2d1b4 Mon Sep 17 00:00:00 2001 From: giavaphi Date: Fri, 25 Nov 2022 02:29:07 +0100 Subject: [PATCH] init css file and bind with app --- .../java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java | 5 ++++- .../ch/zhaw/gartenverwaltung/TextFieldFormular.fxml | 3 ++- .../resources/ch/zhaw/gartenverwaltung/bootstrap/styles.css | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/ch/zhaw/gartenverwaltung/bootstrap/styles.css diff --git a/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java b/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java index 59a4f7d..9c14010 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/bootstrap/AppLoader.java @@ -73,7 +73,10 @@ public class AppLoader { public Object loadSceneToStage(String fxmlFile, Stage appendee) throws IOException { FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(HelloApplication.class.getResource(fxmlFile))); Pane root = loader.load(); - appendee.setScene(new Scene(root)); + Scene scene = new Scene(root); + String css = Objects.requireNonNull(this.getClass().getResource("styles.css")).toExternalForm(); + appendee.setScene(scene); + scene.getStylesheets().add(css); Object controller = loader.getController(); annotationInject(controller); return controller; diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/TextFieldFormular.fxml b/src/main/resources/ch/zhaw/gartenverwaltung/TextFieldFormular.fxml index 2d4dfdc..c02dc37 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/TextFieldFormular.fxml +++ b/src/main/resources/ch/zhaw/gartenverwaltung/TextFieldFormular.fxml @@ -7,7 +7,8 @@ - + diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/bootstrap/styles.css b/src/main/resources/ch/zhaw/gartenverwaltung/bootstrap/styles.css new file mode 100644 index 0000000..f0fea6e --- /dev/null +++ b/src/main/resources/ch/zhaw/gartenverwaltung/bootstrap/styles.css @@ -0,0 +1,6 @@ +.button{ + -fx-text-fill: rgb(49, 89, 23); + -fx-border-color: rgb(49, 89, 23); + -fx-border-radius: 5; + -fx-padding: 3 6 6 6; +} \ No newline at end of file