Image class and paths relative to classpath
martin.sladecek at oracle.com
Mon Apr 23 07:58:09 PDT 2012
this JIRA request is about adding support for "URL" in Image constructor
that is interpreted as a classpath-relative path when a leading slash is
However, this is currently interpreted as absolute file URL.
In order not to break current behaviour I propose to introduce new set
of static factory methods.
Image.fromClassPath(String path, double requestedWidth, double
requestedHeight, boolean preserveRatio, boolean smooth, boolean
+ overloaded method similar to Image constructors.
The idea is to interpret paths with leading slash as absolute to the
classpath root (basically the same as
while relative paths might be interpreted as relative to the caller
class. So Image.fromClassPath("duke.jpg") called from
myapplication.Application will look for the file in myapplication package.
What do you think?
More information about the openjfx-dev