944,181 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 5352
  • Java RSS
Aug 24th, 2005
0

diplaying .gif image in JApplet

Expand Post »
currently using JBuilder Foundations
task is to display a .gif file in JApplet from my hardrive
the URL is C:\MAGIX
Should the image file be located elsewhere in a specific place?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class Applet1 extends JApplet {

public void init(){
Container contentPane=getContentPane();
ImageIcon icon=new ImageIcon("icon.gif");
JLabel jl=new JLabel("icon",icon,JLabel.CENTER);
contentPane.add(jl);
}
}

when running the JApplet, only prints "icon"
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MastaPho is offline Offline
3 posts
since Aug 2005
Aug 25th, 2005
0

Re: diplaying .gif image in JApplet

applet security restrictions prevent you from reading anything from your harddrive.
You can only read files from network addresses on the same server (or more correctly (virtual) host) as the one where the applet resides.
As the applet is in your case not coming from a server it can't read anything at all.
Maybe if you place the applet and file in the same directory you can access it, but that would be due to VM specific laxness rather than official policy.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Aug 25th, 2005
0

Re: diplaying .gif image in JApplet

I've never dealt with icons on an applet, but whenever I wanted to draw an image onto the applet I never had a problem if I put it in the same file. Why don't you check the java console and see if it's a security restriction or if it's a FileNotFoundException.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Subset of Hashtable...
Next Thread in Java Forum Timeline: plz! its urgent





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC