| | |
diplaying .gif image in JApplet
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2005
Posts: 3
Reputation:
Solved Threads: 0
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"
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"
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.
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.
![]() |
Similar Threads
- ULead Cool 3D *gif importing (Graphics and Multimedia)
- displaying gif image (JSP)
- I Need Help Making A Rollover Image! (Geeks' Lounge)
- edit text on a gif image in photoshop (Graphics and Multimedia)
Other Threads in the Java Forum
- Previous Thread: Subset of Hashtable...
- Next Thread: Create an Access Database using Java
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arc arguments array arrays automation binary bluetooth c++ chat class classes client code codesnippet component csv database doctype draw ebook eclipse error event exception fractal freeze game givemetehcodez graphics gui html ide image input integer intellij iphone j2me java java.xls javaprojects jmf jni jpanel julia linux list loop loops mac map method methods mobile netbeans newbie number online oracle page parameter plazmic print problem program programming project recursion reporting rotatetext scanner screen sell server set size sms socket sort sourcelabs sql string superclass swing system template test testautomation threads time title tree tutorial-sample windows working






