aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Extracting Image From A Jar File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Extracting Image From A Jar File" Watch "Extracting Image From A Jar File" New topic
Author

Extracting Image From A Jar File

Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Dear Pals,
I followed the tutorial provided in JavaWorld to to Extract an Image from a JAR File
But in the middle, I am in problem.

I am seeing the button in the north with image, but the center button is without image and the canvas is totally not displayed. I am expecting the center "Hello" button display an imageicon. My comannd line displays the following
jarTest.JarResources@784386 --- ashik 1 and
sun.awt.windows.WImage@171afc --- ashik 2
Waiting for your response on where did I miss?
:roll:


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I got your code to work with some small modifications... I'm not sure why your second image isn't displaying. Is there anything special about the images you are trying to display? All the images I displayed from the JAR file displayed correctly... make sure file names are correct, and that the image isn't corrupted.

As far as why the canvas isn't showing up... the default size of a Canvas is 0x0, so just change it to something large enough to display the image in the constructor. (Also, it's a bad idea to mix AWT components like Canvas with Swing components... you will run into problems down the road...)


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Dear Nate,
I am also where I am mistaking...Would you like to mail me your .java file and the .class file at azaman75@yahoo.com? I would be very pleased to you...
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The only thing I changed in the JAR reading part were the names of the images and the JAR file...

But I'll go ahead and post the code I have now...

Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Nate, thank you very much. Your code is running in my machine. Now I'll find out where did I make the mistake and let you know.
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Nate, thank you very much. Your code is running in my machine. Now I'll find out where did I make the mistake and let you know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extracting Image From A Jar File