Re: How do I put pictures in my Frame?
very basic question from a beginner..
A good group for beginners is comp.lang.java.help.
I need to know how to include a picture in my frame. This script
/ just look at the script, you don't need to understand what it says)
What if it says 'any student found to be seeking
external help will be charged with academic
..works perfectly for an Applet, ..
It is extremely unfortunate that most examples of images
and audio clips rely on those idiotic* applet methods.
(* Idiotic in the sense that, they were not really much more
appropriate to 'tag on' to the Applet class, than the
Frame or Window class - if one, it should have been all)
...but when I try to use the methods for my
Frame, the compiler always says something like "Cannot Resolve Symbol"
and it points to the g in "getCodeBase(), "
That means the class you are using, does not have
any such 'getCodeBase()' method. Check things like
that in the JavaDocs*, for best results.
What can I do to use pictures in Frames?
Look first to.. (* e.g. of JavaDocs)
, then the more useful form that accepts an URL, and their
For the replacement to getCodeBase(), you can either..
1) put the image on the project classpath, and call
2) Get a File object pointing to the image and call File.toURL()
...to get an URL.
Note that it is best to have your own copy of the JavaDocs
to browse locally - they can be downloaded.