Results 1 to 2 of 2

Thread: JavaFX external CSS stylesheet, why doesn't this work?

  1. #1
    Join Date
    Jan 2013
    Posts
    146
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default JavaFX external CSS stylesheet, why doesn't this work?

    EDIT: Nevermind after 2 days of searching for an answer realized i was using () brackets where i needed to use {}

    Here's the java code
    java Code:
    package mainStage;
    import javafx.application.Application;
    import javafx.geometry.Insets;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.layout.GridPane;
    import javafx.stage.Stage;

    public class MainStage extends Application{
        Stage window;
       
        public static void main(String[] args) {
            launch(args);
        }

        @Override
        public void start(Stage primaryStage) throws Exception {
            window = primaryStage;
           
            Button clicker = new Button("Click Me!");
            clicker.setOnAction(e -> System.out.println("Click clickitty"));
           
            GridPane layout = new GridPane();
            layout.setPadding(new Insets(10, 10, 10, 10));
            layout.getChildren().add(clicker);
            layout.setId("layout");
            //layout.setStyle("-fx-background-color: #383838;");
           
            Scene scene = new Scene(layout, 300, 200);
            scene.getStylesheets().add("mainStage/Stylesheet.css");
           
            window.setScene(scene);
            window.show();
           
        }

    }

    Here is my css
    css Code:
    .root{
        -fx-background-color: #383838;
    }

    Im Back... Previously known as Megaleech
    [Herbalife]

  2. #2
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    heh, rip.

    if it makes you feel a little bit better.. https://villavu.com/forum/showthread.php?t=116459

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •