This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I'm having some trouble figuring out what is the best, most reliable, cross-platform method of getting a handle on an Image object from the local filesystem. I'm noticing some confusing methods in the API but have worked around them and have something working on a Wintel platform but I want to make it as platform-agnostic as possible. Two (2) methods exist in the Toolkit API: public abstract Image getImage( java.lang.String ) and public abstract Image getImage( java.net.URL ) I've noticed in my development wanderings that the String object passed is not noted as being relative to the class/package or to "root". I'm saying this because, given a directory "images" under the package, the String "images/imagex.gif" will return null, but the String "/images/imagex.gif" works, as does the String "C:/.../images/imagex.gif". Where is the proper String path documented? My second dilemma is which method is better? I saw a Swing example using: ClassLoader.getSystemResource( java.lang.String ) where the String object passed is a relative path to the image, i.e. "images/imagex.gif". The static method getSystemResource returns a URL object from relative to the CLASSPATH defined on the system. This seems to be very platform agnostic and preferred in cross platform development, but I have not found any notes that this is good/bad/ugly. Can anyone help this conflicted developer? Thanks a ton. Tim
Timothy Stone, MIT, SCJP
"This Satan's drink [coffee] is so delicious, we shall cheat Satan and baptize it." --Pope Clement the VIII (1592-1605)