I am new to JavaFX 2.0 and to do practice I have followed the Oracle example about Line Chart (Stock Monitoring) http://docs.oracle.com/javafx/2.0/charts/line-chart.htm#CIHGBCFI
Now I would like to ad a CSS class in the same package to modify Stroke, color, etc but I can't succed.
Searching here on StackOverflow I have found
scene.getStylesheets().add(this.getClass().getResource("linechart.css").toExternalForm());
but I still get errors
Exception in Application start method Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
My java class name is JavaFXApplication2 and CSS class name is linechart.css
Would someone be so kind to explain me where I am wrong?
There is another nice tutorial about the CSS use with Stock Monitoring example here http://docs.oracle.com/javafx/2.0/charts/css-styles.htm
but I do not know how to add the CSS examples to the java class
Thanks
NullPointerExceptionmay occur if thesceneis not yet initialized or if thelinechart.cssfile does not exist. Double check the CSS file name and its location in a package. Alternatively you can post yourstart(Stage primaryStage)method inJavaFXApplication2here. - Uluk BiySystem.out.println(this.getClass().getResource(".").toExternalForm());and copy the css file to the folder path printed by this line. - Uluk Biy