• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extracting Image From A Jar File

 
Ranch Hand
Posts: 2378
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...)
 
Ashik Uzzaman
Ranch Hand
Posts: 2378
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2378
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2378
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic