Solved

JApplet + image

Posted on 2000-03-27
5
420 Views
Last Modified: 2012-06-27
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
Comment
Question by:s_lavie
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:muraliram
Comment Utility
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
 
LVL 2

Expert Comment

by:stalefish
Comment Utility
post your code
0
 
LVL 2

Author Comment

by:s_lavie
Comment Utility
Dear Murali,

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

Thanks,

s_lavie
 




0
 
LVL 2

Accepted Solution

by:
muraliram earned 50 total points
Comment Utility
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
 
LVL 2

Author Comment

by:s_lavie
Comment Utility
I can't accept a comment as an answer, since the question is 'unlocked'.
Thanks anyway for that answer.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now