我在用
SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(MyJSlider.class.getResourceAsStream("/ui/demo.xml"), MyJSlider.class);
//laf.load(new URL("file:///var/tmp/demo.xml"));
我的 demo.xml 有以下内容:
<style id="SliderTrackStyle">
<opaque value="TRUE"/>
<state>
<imagePainter method="SliderTrackBackground" path="/var/tmp/JavaUnitTest/src/image/menu/bg.jpg" sourceInsets="0 0 0 0" />
</state>
</style>
<bind style="SliderTrackStyle" type="region" key="SliderTrack" />
导致错误:
run-single:
Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:115)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:125)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:263)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)
BUILD STOPPED (total time: 9 seconds)
避免和减少风险。
我怎样才能像path=Menu.class.getResourceAsStream("/image/menu/bg.jpg")
我想避免使用示例中显示的静态路径一样使用它。
跟进: