Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Marzoog AlGhazwi
15,796 PointsWARNING: Resource "/css/sample.css" not found.
Can someone help me to fix this !?
<GridPane fx:controller="sample.Controller"
stylesheets="/css/sample.css"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10"
style="-fx-font-family: Papyrus">
5 Answers

Jan Bičan
19,777 PointsHi, I had the same problem. Solution is to write it like this: stylesheets="@../css/sample.css"

Luka Sarich
13,204 PointsThank you for sharing this!

Greg Witt
27,132 PointsThis did not work my guy more confusion

Greg Witt
27,132 PointsFixed it!!!
Alright so there is a nice link to an awesome tutorial that shows the class implementation of the getResource()
function being used to help solve any one's issues.
This is what I did inside of the Main.java
to dissolve any additional headaches
Check out the tutorial on that link for a cool demo project as well.
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("/fxml/sample.fxml"));
GridPane example = (GridPane) root;
// Group root = new Group();
// Text txt = new Text("Sup?");
// txt.setFont(new Font("Papyrus", 80));
// Label label = new Label("Name:");
// TextField nameFld = new TextField();
////Creates the Gridpane layout
// GridPane grid = new GridPane();
//
//// Add Items to the grid and specify the layout
//// gridlineshelp for visual debugging
//// grid.setGridLinesVisible(true);
// grid.add(label, 0, 0);
// grid.add(nameFld, 1, 0);
//// Adds the btn to the second column and the second row
// Button btn = new Button();
// btn.setText("Say Sup!");
//
// grid.add(btn, 1, 1);
//
// //Sets the Height gap distance
// grid.setHgap(20);
//
//
// txt.setY(50);
//
// VBox box = new VBox();
// box.getChildren().addAll(txt, grid);
// root.getChildren().add(box);
//// Sets an event listener to listen to the action that was taken with a lambda function
// btn.setOnAction(evt -> System.out.printf("Sup %s!%n", nameFld.getText()));
primaryStage.setTitle("Sup");
primaryStage.setScene(new Scene(root, 300, 275));
// THIS IS THE CODE I ADDED TO FIX THE PROBLEM
root.getStylesheets().add(getClass().getResource("/css/sample.css").toExternalForm());
// THIS IS THE CODE I ADDED TO FIX THE PROBLEM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

Fabian Pijpers
Courses Plus Student 41,372 Pointsmaybe your css source file is either not included or their is a problem with workspaces .

Fabian Pijpers
Courses Plus Student 41,372 PointsMaybe technical problem with workspaces.

Fabian Pijpers
Courses Plus Student 41,372 PointsThanks it is a good thing to help and remind each other as students and users alike that all platforms have the occasional hickups! and resolve them.
Fabian Pijpers
Courses Plus Student 41,372 PointsFabian Pijpers
Courses Plus Student 41,372 PointsMistake in workspaces