Solved

JApplet + image

Posted on 2000-03-27
5
424 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
ID: 2660927
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
ID: 2662408
post your code
0
 
LVL 2

Author Comment

by:s_lavie
ID: 2663363
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
ID: 2663871
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
ID: 2664127
I can't accept a comment as an answer, since the question is 'unlocked'.
Thanks anyway for that answer.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate jars 4 57
Is there a simpler dropbox system? 10 44
Java array 10 53
Java array 21 75
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

679 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