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?
LVL 2
s_lavieAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
muraliramConnect With a Mentor Commented:
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
 
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
 
s_lavieAuthor Commented:
I can't accept a comment as an answer, since the question is 'unlocked'.
Thanks anyway for that answer.
0
All Courses

From novice to tech pro — start learning today.