Re: Loading icons out of a jar file
Mathias Payer <[email protected]> Fri, 17 Sep 2004 10:01:00 +0200
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Organization | ETH Zurich |
| Message-ID | <[email protected]> |
Hi List!
First of all: Thanks Frank for your input!
> there is no need to render the xml file like this. Just put your
> StartUp.xml in your classpath and write it like this:
> Container container = swix.render("StartUp.xml");
This worked fine, thanks
> (I usally have a separated "resource" folder containing my
> SwixML-XML-files, icons and the like. This resource folder is put in
> the classpath.)
I'm putting everyhting into one JAR-File, the application, the xml files
and the icons (images), because this application will not be too large.
Now I'v got everything in the JAR File, something is done but the image
is not displayed!
--SNIP--
<button id="btn_EMail" mnemonic="mn_btn_EMail" name="btn_EMail"
Action="SwitchFunction" ActionCommand="Frame_EMail" Icon="img_EMail"
FocusPainted="false" ToolTipText="ttt_btn_EMail"/>
<button id="btn_Calendar" mnemonic="mn_btn_Calendar" name="btn_Calendar"
Action="SwitchFunction" ActionCommand="Frame_Calendar"
Icon="yggdrasil/icons/test.gif" ToolTipText="ttt_btn_Calendar"
enabled="true" BorderPainted="true" FocusPainted="false"
size="24,24"/>
--SNAP----
Both buttons acces the same gif-file. The first one is with i18n and the
second without.
I think the image gets loaded as there is some space left for the image
and you can see the border of the image when the button is selected.
After a lot of testing I tried the following:
--SNIP--
ImageIcon img = new
ImageIcon(swix.getLocalizer().getClassLoader().getResource("yggdrasil/i
cons/test.gif"));
System.out.println(img+"\n"+img.getIconWidth()+" "+img.getIconHeight());
btn_Addressbook.setIcon(img);
btn_Addressbook.validate();
MainUIFrame.validate();
--SNAP--
I set the Image of a Button manually. And I discover the same behavior
like the buttons in the XML File.
The Output on the console is the following:
--SNIP--
jar:file:/home/gannimo/Verschiedenes/Programmierung/Yggdrasil/build/ygg
drasil.jar!/yggdrasil/icons/test.gif
16 16
--SNAP--
This tells me that the image is found and can be accessed.
But why isn't it displayed?
I valled validate to repaint the screen and display the changes.
I also tried the localization and other examples, there all icons work,
but they are not loaded from a jar-file?
Has anybody any idea what I'm doing wrong?
Or what I could do to solve this problem?
Thanks in advance!
Greats
Mathias
------------
GPG-Key: http://relay.gmgnet.li/gpg-keys/payerm_student_ethz_ch.key
Kontakt-Infos: http://relay.gmgnet.li/mathias_payer/kontakt.html
_______________________________________________
Forum mailing list
[email protected]
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iEYEARECAAYFAkFKmcAACgkQqkE3W4yIscGA7QCePlntruiUs3Y3YUgiBdWAuJAV OXoAnAqd8rnqvMjJoEsHMmjca686wEeK =dTHk -----END PGP SIGNATURE-----