> 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)


Reply via email to