From 80aeeaa95ea9114880fdac8e899e8ad484da9d93 Mon Sep 17 00:00:00 2001 From: Brian Patino Date: Sun, 7 Feb 2016 01:00:02 -0500 Subject: [PATCH] Fix Stylesheet * add style example --- src/main/java/Controller.java | 2 +- src/main/java/Main.java | 11 +++++------ src/main/resources/mainStyle.css | 34 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/mainStyle.css diff --git a/src/main/java/Controller.java b/src/main/java/Controller.java index a3f7103..a905ef4 100644 --- a/src/main/java/Controller.java +++ b/src/main/java/Controller.java @@ -19,7 +19,7 @@ public class Controller{ @FXML private void initialize() { - createTree(); +// createTree(); } // Create the directory Tree diff --git a/src/main/java/Main.java b/src/main/java/Main.java index ee5dff3..49fda7f 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -13,7 +13,7 @@ public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception{ - setUserAgentStylesheet(STYLESHEET_CASPIAN); +// setUserAgentStylesheet(STYLESHEET_CASPIAN); /* Button btn = new Button(); btn.setText("This is a test"); btn.setOnAction(new EventHandler() { @@ -24,13 +24,12 @@ public void handle(ActionEvent event) { });*/ Parent root = FXMLLoader.load(getClass().getResource("StartPage.fxml")); - Scene scene = primaryStage.getScene(); Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds(); - - //scene.getStylesheets().add("style_main.css"); //Error here... - primaryStage.setTitle("Iron-gate!"); - primaryStage.setScene(new Scene(root, screenBounds.getWidth(), screenBounds.getHeight())); + primaryStage.setScene(new Scene(root, screenBounds.getWidth(), screenBounds.getHeight())); // a scene is created here + Scene scene = primaryStage.getScene(); // we get the scene from above + scene.getStylesheets().clear(); // clear any styles + scene.getStylesheets().add("/main/resources/mainStyle.css"); // absolute path primaryStage.show(); } public static void main(String[] args) { diff --git a/src/main/resources/mainStyle.css b/src/main/resources/mainStyle.css new file mode 100644 index 0000000..f2a03ae --- /dev/null +++ b/src/main/resources/mainStyle.css @@ -0,0 +1,34 @@ + +/* + Document : controlStyle1 +*/ + +.root{ + -fx-font-size: 14pt; + -fx-font-family: "Tahoma"; + -fx-base: #DFB951; + -fx-background: #A78732; + -fx-focus-color: #B6A678; +} + +.button1{ + -fx-text-fill: #006464; + -fx-background-color: #DFB951; + -fx-border-radius: 20; + -fx-background-radius: 20; + -fx-padding: 5; +} + +.button2{ + -fx-text-fill: #c10000; + -fx-background-color: #DFB951; + -fx-border-radius: 20; + -fx-background-radius: 20; + -fx-padding: 5; +} + +.slider{ + -fx-border-color: white; + -fx-border-style: dashed; + -fx-border-width: 2; +}