here is a screenshoot of the hierarchy of my project :(https://i.stack.imgur.com/pY7uI.png)
here is the code source : StylingLoginPage.java:
package com.example.loginpage;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.geometry.Insets;
import javafx.scene.layout.GridPane;
import javafx.application.Application;
public class StylingLoginPage extends Application {
public static void main (String[] args){
launch(args);
}
@Override
public void start (Stage primaryStage){
primaryStage.setTitle("CSS styling");
//Name Label:
Label namelabel = new Label("Username");
GridPane.setConstraints(namelabel,0,0);
//Username Input:
TextField nameInput = new TextField();
nameInput.setPromptText("Enter your name");
GridPane.setConstraints(nameInput,1,0);
//password Label:
Label pwdlabel = new Label("password");
GridPane.setConstraints(pwdlabel,0,1);
//Password Input:
TextField pwdInput = new TextField();
pwdInput.setPromptText("Enter your password");
GridPane.setConstraints(pwdInput,1,1);
//Login Button:
Button loginButton = new Button("Login");
GridPane.setConstraints(loginButton ,1,2);
//EventHandler:
loginButton.setOnAction(e->System.out.println("User loged in .."));
//Layout:
GridPane gridpane = new GridPane();
gridpane.setPadding(new Insets(10,10,10,10));
gridpane.setVgap(10);
gridpane.setHgap(10);
gridpane.getChildren().addAll(namelabel,nameInput,pwdlabel,pwdInput,loginButton);
//Scene:
Scene scene = new Scene(gridpane,300,300);
scene.getStylesheets().add("login-style.css");
primaryStage.setScene(scene);
primaryStage.show();
}
}
login-style.css
.root{
-fx-background-color:#383838;
-fx-font-size:11pt;
}
I'm building a login Page using javaFX and i tried to include some CSS style in my project . Wether i'm working on Eclipe or intellij IDEA, I'm getting the sam error: *com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged WARNING: Resource "login-style.css" not found. *