尝试在 JavaFX 2.2(来自 JDK 7 更新 11)中使用我自己的自定义 css 时,我将以下异常记录到 stderr。这很有趣,因为 css 实际上是在我的应用程序中找到并使用的,所以唯一错误的是日志中的异常。我也以这种方式加载其他资源(图像、字体等),并且在这些情况下没有记录异常。
我正在像这样加载css:
val cssResource = getClass.getResource("/com/openaf/browser/gui/resources/openaf.css").toExternalForm
println("CSS Resource: " + cssResource)
println("")
scene.getStylesheets.add(cssResource)
你可以从输出中看到它被发现(我不确定为什么在异常中它说* *.bss 但也许那是 felix 做一些内部包重命名。
有谁知道为什么要记录此异常和/或如何摆脱它?
CSS Resource: bundle://21.57:1/com/openaf/browser/gui/resources/openaf.css
java.io.IOException: Resource does not exist: bundle://21.57:1/com/openaf/browser/gui/resources/openaf.bss
java.io.IOException: Resource does not exist: bundle://21.57:1/com/openaf/browser/gui/resources/openaf.bss
at org.apache.felix.framework.URLHandlersBundleURLConnection.<init>(URLHandlersBundleURLConnection.java:136)
at org.apache.felix.framework.URLHandlersBundleStreamHandler.openConnection(URLHandlersBundleStreamHandler.java:64)
at java.net.URL.openConnection(URL.java:971)
at java.net.URL.openStream(URL.java:1037)
at com.sun.javafx.css.Stylesheet.loadBinary(Stylesheet.java:201)
at com.sun.javafx.css.StyleManager.loadStylesheetUnPrivileged(StyleManager.java:572)
at com.sun.javafx.css.StyleManager.loadStylesheet(StyleManager.java:411)
at com.sun.javafx.css.StyleManager.updateStylesheets(StyleManager.java:858)
at javafx.stage.Window.impl_visibleChanging(Window.java:818)
at javafx.stage.Stage.impl_visibleChanging(Stage.java:922)
at javafx.stage.Window$10.invalidated(Window.java:689)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
at javafx.stage.Window.setShowing(Window.java:782)
at javafx.stage.Window.show(Window.java:797)
at javafx.stage.Stage.show(Stage.java:229)
at com.openaf.browser.gui.BrowserStageManager.createStage(BrowserStageManager.scala:64)
at com.openaf.browser.gui.BrowserStageManager.start(BrowserStageManager.scala:41)
at com.openaf.browser.gui.BrowserBundleActivator$$anonfun$startUp$2.apply$mcV$sp(BrowserBundleActivator.scala:32)
at com.openaf.browser.gui.utils.BrowserUtils$$anon$1.run(BrowserUtils.scala:48)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)