| | |
load image in applet
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Mar 2006
Posts: 78
Reputation:
Solved Threads: 0
Hi,
I am trying to load an image into an applet, however unsuccessfully.
What's wrong here?
I am trying to load an image into an applet, however unsuccessfully.
What's wrong here?
Java Syntax (Toggle Plain Text)
package sess31; // Import the AWT graphics package import java.awt.*; import java.applet.*; public class myownapplet extends Applet { Image image; public void init() { // Load image //image = getImage(getDocumentBase(), "show14.gif"); } public void paint(Graphics g) { // Draw image g.drawImage(image, 0, 0, this); } }
1
#2 Oct 11th, 2009
Hi,
I can't see any faults in your code, so my guess is that the program is unable to find the image.
If your folder structure looks like this:
.\src\sess31\myownapplet.java
then place the image like this:
.\src\image.gif
or specify the location in the path.
Hope this helps!
I can't see any faults in your code, so my guess is that the program is unable to find the image.
If your folder structure looks like this:
.\src\sess31\myownapplet.java
then place the image like this:
.\src\image.gif
or specify the location in the path.
Hope this helps!
---------------------------
333 - halfway to hell
333 - halfway to hell
•
•
Join Date: Mar 2006
Posts: 78
Reputation:
Solved Threads: 0
0
#3 Oct 11th, 2009
Thank you for your answer.
At the moment I have the image file in that location but the image is not appearing in the applet.
However if I try with the same image from an URL, it works:
I don't get it why is this. Should the image file be in another location?
At the moment I have the image file in that location but the image is not appearing in the applet.
However if I try with the same image from an URL, it works:
Java Syntax (Toggle Plain Text)
image = getImage(getDocumentBase(), "http://www.iki.rssi.ru/IPL/show14.gif");
I don't get it why is this. Should the image file be in another location?
•
•
•
•
Hi,
I can't see any faults in your code, so my guess is that the program is unable to find the image.
If your folder structure looks like this:
.\src\sess31\myownapplet.java
then place the image like this:
.\src\image.gif
or specify the location in the path.
Hope this helps!
•
•
Join Date: Mar 2006
Posts: 78
Reputation:
Solved Threads: 0
0
#7 Oct 11th, 2009
It works now, thank you very much for the help.
I didn't know that the image had to be in the build folder.
Cheers!
I didn't know that the image had to be in the build folder.
Cheers!
![]() |
Similar Threads
- Loading image in an Applet (Java)
- Applet (Java)
- Help to show updated image in applet [Sort of chaninging graph] (Java)
- how to load image in java using applets? (Java)
- How do i load a image on the same page ? (Site Layout and Usability)
- how to load an image in c file (C)
- how to load an image to a form (Visual Basic 4 / 5 / 6)
Other Threads in the Java Forum
- Previous Thread: Player at the Java application
- Next Thread: Need Help on how to output data in table looking format
| Thread Tools | Search this Thread |
Tag cloud for applet, image
.net animated animation api applet array back backup bmp broken button byte c# checkbox clear clone cloning code directory disk displayimageinsteadofflash draw drive embedded event file flash format free game gdi ghost google grid hard header helpwithhomework hosting image images ip jar jarfile java jmf jpanel jpeg link mediawiki method multimedia mysql open panel php picture picturebox problem project random reading reputationmanagement resource screen scroll search security shot signing socket subdomain swf swf. swing tcp transfer upload url view web webbrowser website windows






