Classpath-relative URLs in CSS

Richard Bair richard.bair at oracle.com
Thu May 31 17:31:28 PDT 2012


I think absolute paths without a scheme (ie: /foo/bar/baz) will be relative to the classpath.

On Apr 2, 2011, at 1:06 PM, Daniel Zwolenski wrote:

> I'd like to be able to do them relative to the classpath too. I think we've seen this conversation before, what happened to the "classpath://" URL idea?
> 
> The W3C aren't building java applications. 
> 
> Cheers,
> Dan
> 
> 
> On 01/06/2012, at 3:54 AM, David Grieve <david.grieve at oracle.com> wrote:
> 
>> URLs in a stylesheet are relative to the stylesheet itself. This is per W3C standard. 
>> 
>> On May 31, 2012, at 1:42 PM, Werner Lehmann wrote:
>> 
>>> Hi,
>>> 
>>> last month I learned that FXML can process absolute paths (relative to
>>> the root of the classpath, see quoted portion below). It would be nice to have the same in css as well:
>>> 
>>>> -fx-background-image: url("/some/source/folder/arrow.png");
>>> 
>>> Currently I have to do this instead:
>>> 
>>>> -fx-background-image: url("../../../arrow.png");
>>> 
>>> And when the css file is moved to a different package I have to remember
>>> to update the relative urls. Also, it does not seem to work with
>>> resources inherited from a dependency project (might be an Eclipse issue
>>> but I suppose it would work if the class loader was used).
>>> 
>>> The css reference says:
>>> 
>>>> "/com/wicked/cool/resources/styles.css" is treated as
>>>> "com/wicked/cool/resources/styles.css". This is consistent with FXML.
>>> 
>>> It seems logical to support this not only for the stylesheet but also for urls in the stylesheet, just like urls in FXML...
>>> 
>>> Rgds
>>> Werner
>>> 
>>> 
>>> On 23.04.2012 18:40, Greg Brown wrote:
>>>>> Correct me if I am wrong but today FXML seems to support relative
>>>>> paths only. For instance, if I have a shared image resource
>>>>> "warning.png" in the root of the classpath, I have to specify it
>>>>> like "../../../../warning.png" in the FXML, depending on which
>>>>> package the FXML is in.
>>>> 
>>>> Currently, you can specify either a relative path (e.g.
>>>> "../../warning.png") or an absolute path (relative to the classpath;
>>>> e.g. "/warning.png") in FXML. This works for includes, script files,
>>>> and attributes with a leading "@" symbol.
>>>> 
>>>> G
>> 
>> 
>> David Grieve | Principal Member of Technical Staff
>> Mobile: +16033121013 
>> Oracle Java Client UI and Tools
>> Durham, NH 03824 
>> Oracle is committed to developing practices and products that help protect the environment
>> 



More information about the openjfx-dev mailing list