I got an error:
java.lang.NullPointerException
at org.apache.pivot.wtk.media.Image$LoadTask.execute(Image.java:97)
at org.apache.pivot.wtk.media.Image.load(Image.java:144)
at org.apache.pivot.demos.memorygame.Main.startup(Main.java:46)
at
org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:594)
at
org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1474)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
2010/12/9 Greg Brown <[email protected]>
> 2010/12/8 Greg Brown <[email protected]>
>
>> Ah, I see. You are calling ButtonData#setIcon(String) with that value.
>> That method obtains the location of the image as relative to the classpath,
>> so the leading "/" is required.
>>
>
> When using Pivot 1.5.2 I didn't need the leading "/". Well, I'll use it
> from now =)
>
>
> Yes, that is something that changed in 2.0.
>
> I would probably use the setIcon(Image) version, and define a default Image
>> instance by calling Image.load(). But either way will work.
>>
>
> I tried use the version you suggested, but I got an error
> (MalformedURLException).
> Where am I missing something? See:
>
>
> ...
> private String defaultImage = "/img/default.gif";
> private Image defaultImg;
> ...
>
> defaultImg = Image.load(new URL(defaultImage));
>
>
> Try this:
>
> defaultImg = Image.load(getClass().getResource("img/default.gif"));
>
> (no leading slash)
>
>
>
--
Luiz Gustavo S. de Souza
http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso