我目前正在尝试进入 JavaFX 2.0,但我无法让.css
样式表在我的应用程序中工作。我已经按照http://docs.oracle.com/javafx/2/get_started/css.htm#BABBGJBI上的指南进行操作,但是每当我尝试.css
通过
scene.getStylesheets().add(Login.class.getResource("loginform.css").toExternalForm());
我收到以下错误:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:399)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at Login.start(Login.java:68)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:315)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:174)
at com.sun.javafx.application.PlatformImpl$3.run(PlatformImpl.java:141)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62)
... 1 more
css路径位于我的eclipse项目路径中:
C:\Users\UserName\Dropbox\Documents\Eclipse\FirstExamples\loginform.css
我会很感激任何帮助,我无法让它工作,不是绝对路径,也不是示例中所示的相对路径。