我如何在CSSfx项目中集成CSS?

时间:2019-03-05 08:19:20

标签: css javafx

我正在尝试将背景和按钮样式集成到我的测验项目中。 但是我无法到达CSS。

我有以下样式表(mainstyle.css):

.root{
    -fx-background-image: url("/afbeeldingen/Achtergrond/background_image.jpg");
    -fx-background-repeat:stretch;
    -fx-background-size: 600 1000;
    -fx-background-position: center center;
    -fx-effect: dropshadow(three-pass-box,black,30,0.5,0,0);
}

.Button {
    -fx-font-size: 48;
    -fx-background-color: blue;
    -fx-font-weight: bold;
    -fx-border-width: 2;
    -fx-border-radius: 10;
    -fx-padding: 5 20 5 20;
}

.choice-box{-fx-background-color: yellow;
}

以及de Quizapp中的以下实现

public class QuizApp extends Application {

    @Override
    public void start(Stage primaryStage) {
        Lijst model = new Lijst();
        QuizView view = new QuizView();
        QuizPresenter presenter = new QuizPresenter(model,view);
        Scene scene = new Scene(view);
        scene.getStylesheets().add(this.getClass().getResource("mainStyle.css").toExternalForm());
        primaryStage.setTitle("LANDENQUIZ");
        primaryStage.setScene(scene);
        primaryStage.setWidth(1000);
        primaryStage.setHeight(600);
        primaryStage.setResizable(false);
        primaryStage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }
}

但是我看不到背景图片或其他样式...

0 个答案:

没有答案