From 850381769a4cd2ed4259793af4816fa9a61ebef2 Mon Sep 17 00:00:00 2001 From: Jonas Hinterdorfer Date: Tue, 13 May 2025 10:34:42 +0200 Subject: [PATCH] implemented better style --- .../java/at/ionas999/questioncatalog/App.java | 6 +- .../at/ionas999/questioncatalog/Utils.java | 1 - src/main/java/module-info.java | 2 +- .../at/ionas999/questioncatalog/style.css | 114 ------------------ 4 files changed, 6 insertions(+), 117 deletions(-) delete mode 100644 src/main/resources/at/ionas999/questioncatalog/style.css diff --git a/src/main/java/at/ionas999/questioncatalog/App.java b/src/main/java/at/ionas999/questioncatalog/App.java index 85480e7..17a1ade 100644 --- a/src/main/java/at/ionas999/questioncatalog/App.java +++ b/src/main/java/at/ionas999/questioncatalog/App.java @@ -1,5 +1,9 @@ package at.ionas999.questioncatalog; +import atlantafx.base.theme.CupertinoDark; +import atlantafx.base.theme.CupertinoLight; +import atlantafx.base.theme.PrimerDark; +import atlantafx.base.theme.PrimerLight; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; @@ -11,9 +15,9 @@ public class App extends Application { // Der gesamte fxml code wurde mithilfe des Github Copilotes generiert @Override public void start(Stage stage) throws IOException { + Application.setUserAgentStylesheet(new CupertinoLight().getUserAgentStylesheet()); FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource("main.fxml")); Scene scene = new Scene(fxmlLoader.load(), 320, 240); - scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm()); stage.setTitle("Question Catalog"); stage.setScene(scene); stage.show(); diff --git a/src/main/java/at/ionas999/questioncatalog/Utils.java b/src/main/java/at/ionas999/questioncatalog/Utils.java index ec695a1..b40d7ca 100644 --- a/src/main/java/at/ionas999/questioncatalog/Utils.java +++ b/src/main/java/at/ionas999/questioncatalog/Utils.java @@ -22,7 +22,6 @@ public class Utils { FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxmlFileName)); Parent root = fxmlLoader.load(); Scene scene = new Scene(root); - scene.getStylesheets().add(App.class.getResource("style.css").toExternalForm()); stage.setScene(scene); stage.show(); } diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 4966913..350060e 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,8 +1,8 @@ module at.ionas999.questioncatalog { - requires javafx.controls; requires javafx.fxml; requires java.desktop; requires java.sql; + requires atlantafx.base; opens at.ionas999.questioncatalog to javafx.fxml; opens at.ionas999.questioncatalog.controller to javafx.fxml; // Add this line diff --git a/src/main/resources/at/ionas999/questioncatalog/style.css b/src/main/resources/at/ionas999/questioncatalog/style.css deleted file mode 100644 index 463e5fa..0000000 --- a/src/main/resources/at/ionas999/questioncatalog/style.css +++ /dev/null @@ -1,114 +0,0 @@ -/* antdesign.css */ -/* 1. Root Variables */ -.root { - /* Colors */ - -fx-accent: #1890ff; /* Primary */ - -fx-background: #f5f5f5; /* Page background */ - -fx-control-inner-background: #ffffff; /* Surface */ - -fx-text-base-color: #000000d9; /* High-emphasis text */ - -fx-text-secondary-color: #00000073; /* Disabled text */ - - /* Typography */ - -fx-font-family: "Helvetica Neue", Arial, sans-serif; - -fx-font-size: 14px; -} - -/* 2. Buttons */ -.button { - -fx-background-color: -fx-accent; - -fx-text-fill: white; - -fx-background-radius: 2px; - -fx-padding: 8 16; - -fx-effect: dropshadow( gaussian , rgba(0,0,0,0.16), 6, 0, 0, 3 ); - -fx-cursor: hand; - -fx-transition: background-color 0.2s ease; -} -.button:hover { - -fx-background-color: #40a9ff; /* Primary Hover */ -} -.button:pressed { - -fx-background-color: #096dd9; /* Primary Active */ -} -.button:disabled { - -fx-background-color: derive(-fx-accent, 30%); - -fx-text-fill: -fx-text-secondary-color; -} - -/* 3. Labels */ -.label { - -fx-text-fill: -fx-text-base-color; - -fx-font-weight: 600; /* Semibold */ -} -.label.secondary { - -fx-text-fill: -fx-text-secondary-color; - -fx-font-size: 12px; -} - -/* 4. TextInput & TextArea */ -.text-field, .text-area { - -fx-background-color: -fx-control-inner-background; - -fx-border-color: #d9d9d9; - -fx-border-width: 1; - -fx-background-radius: 2px; - -fx-border-radius: 2px; - -fx-padding: 4 8; - -fx-text-fill: -fx-text-base-color; -} -.text-field:focused, .text-area:focused { - -fx-border-color: -fx-accent; - -fx-effect: dropshadow( gaussian , rgba(24,144,255,0.2), 6, 0, 0, 0 ); -} - -/* 5. ListView */ -.list-view { - -fx-background: transparent; - -fx-border-color: #d9d9d9; - -fx-border-radius: 2px; -} -.list-cell { - -fx-padding: 8 12; - -fx-text-fill: -fx-text-base-color; -} -.list-cell:selected { - -fx-background-color: derive(-fx-accent, -20%); - -fx-text-fill: white; -} - -/* 6. ScrollBar Thumb */ -.scroll-bar .thumb { - -fx-background-color: #d9d9d9; - -fx-background-radius: 2px; -} -.scroll-bar:hover .thumb { - -fx-background-color: #bfbfbf; -} - -/* 7. Tooltips */ -.tooltip { - -fx-background-color: #000000d9; - -fx-text-fill: white; - -fx-padding: 4 8; - -fx-background-radius: 2px; - -fx-font-size: 12px; -} - -/* 8. Dialogs & Popovers */ -.dialog-pane { - -fx-background: -fx-control-inner-background; - -fx-border-color: #d9d9d9; - -fx-border-radius: 2px; - -fx-background-radius: 2px; - -fx-effect: dropshadow( gaussian , rgba(0,0,0,0.16), 12, 0, 0, 4 ); -} - -/* 9. Tabs */ -.tab-pane .tab-header-area .tab { - -fx-background-color: transparent; - -fx-padding: 8 16; - -fx-text-fill: -fx-text-base-color; -} -.tab-pane .tab-header-area .tab:selected { - -fx-background-color: -fx-accent; - -fx-text-fill: white; - -fx-background-radius: 2px 2px 0 0; -}