| Author |
Images in Java
|
Trey German
Greenhorn
Joined: Dec 05, 2002
Posts: 12
|
|
|
I'am having trouble putting images in my java applets can someone please send me some source code that works for sure. All the code that I've found doesn't seem to work. THANX
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
Jungle.gif I found laying around in the MicroSoft stuff on my PC and moved it to my DocumentBase directory (the directory that the HTML holding the Applet sits in).
|
"JavaRanch, where the deer and the Certified play" - David O'Meara
|
 |
Trey German
Greenhorn
Joined: Dec 05, 2002
Posts: 12
|
|
|
Thanx for the code the applet looks like its working but now it just gives me a grey square when i open the applet. I have a feeling its just the computer i'm using but it is doing it on all the computers i've tried do you have any suggestions?
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
|
Is the gif file in the correct directory?
|
 |
Trey German
Greenhorn
Joined: Dec 05, 2002
Posts: 12
|
|
|
Yes. I believe it is in the correct directory.
|
 |
Trey German
Greenhorn
Joined: Dec 05, 2002
Posts: 12
|
|
|
i got it working thanx
|
 |
Trey German
Greenhorn
Joined: Dec 05, 2002
Posts: 12
|
|
Also will the same code work in a java program, and if it doesn't sould you give me some that will THANX
|
 |
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
|
|
Well you can't use DocumentBase of course. You will need to use something like: Image myImage = Toolkit.getDefaultToolkit().createImage(�myPic.jpg�); or Image myImage = Toolkit.getDefaultToolkit().createImage(new URL(�http://www.javaranch.com/Cindy/Cindy2.jpg�));
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Jason Moon
Greenhorn
Joined: Dec 11, 2002
Posts: 3
|
|
|
im still having a little prob with the making an image... Where is the html directory?
|
 |
Dave Vick
Ranch Hand
Joined: May 10, 2001
Posts: 3244
|
|
sporkboy ??? Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however, your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy. Thanks again and we hope to see you around the ranch!!
|
Dave
|
 |
Jason Moon
Greenhorn
Joined: Dec 11, 2002
Posts: 3
|
|
So.. is it in the Jbuilder directory?? Windows??? scr?? i can't find it
|
 |
Jason Moon
Greenhorn
Joined: Dec 11, 2002
Posts: 3
|
|
ok ok ok..... after hours and hours of tedious work.. I imported java.net.*; and used myImage = getImage(new URL("http://www.javaranch.com/Cindy/Cindy2.jpg")); that works but what if I want to get a Image off my own Computer?? Can somone help me??? i've been seriously trying for hours..
|
 |
 |
|
|
subject: Images in Java
|
|
|