Solved

JApplet + image

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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…

911 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

22 Experts available now in Live!

Get 1:1 Help Now