pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gk_br...@verizon.net>
Subject Re: Image Path
Date Thu, 09 Dec 2010 02:31:09 GMT
> 2010/12/8 Greg Brown <gk_brown@verizon.net>
> 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)



Mime
View raw message