Solved

JApplet + image

Posted on 2000-03-27
5
423 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JList custom Cell Renderer refresh 15 56
VB Script to add site to Java Exception List 4 75
diffSum example 4 36
hibernate jars 4 28
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

786 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