Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

JApplet + image

Hi,
I'm trying to implement an applet that loads a frame with an imaged button.
My applet has its button on the html page, and when clicking on it the frame has to appear.
It works fine with out the image, but when I add the line:
ImageIcon img = new ImageIcon(new URL("file:" + imgFullPath));
the frame dosen't appear.
I'm using JApplet as the applet, JFrame as the frame, and JButton as the button.

What is wrong?
0
s_lavie
Asked:
s_lavie
  • 2
  • 2
1 Solution
 
muraliramCommented:
Dear slavie,

    Do one thing

ImageIcon img = new ImageIcon(new URL(getCodeBase() +"imagename.jpg"));

Put the image in the same directory as that of the class file and try.
This may solve the problem

Bye

Murali
 


0
 
stalefishCommented:
post your code
0
 
s_lavieAuthor Commented:
Dear Murali,

Your solution was great.
Post an answer and I'll post your points...

Thanks,

s_lavie
 




0
 
muraliramCommented:
Dear slavie,

Thanks.I think you can accept comment as answer.Anyway I am putting this as an answer as you told

ImageIcon img = new ImageIcon(new URL(getCodeBase() +"imagename.jpg"));

Put the image in the same directory as that of the class file and try.
This may solve the problem

All the best

Bye

Murali
0
 
s_lavieAuthor Commented:
I can't accept a comment as an answer, since the question is 'unlocked'.
Thanks anyway for that answer.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now