diplaying .gif image in JApplet

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2005
Posts: 3
Reputation: MastaPho is an unknown quantity at this point 
Solved Threads: 0
MastaPho MastaPho is offline Offline
Newbie Poster

diplaying .gif image in JApplet

 
0
  #1
Aug 24th, 2005
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"
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: diplaying .gif image in JApplet

 
0
  #2
Aug 25th, 2005
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: diplaying .gif image in JApplet

 
0
  #3
Aug 25th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC