Image class and paths relative to classpath
daniel.fuchs at oracle.com
Tue Apr 24 02:11:16 PDT 2012
The JavaFX SceneBuilder will be able to deal easily with absolute
(eg, "file:/" or "http://") URLs, as well as with relative
("@...") URLs. However dealing with things like "classpath:/..."
will be more challenging.
The issue here is that 1. you need to define your classpath before
loading your FXML - so that the classpath:/ can be resolved, and
2. since you're editing an FXML you might not have anything in
the classpath yet - since you might not have compiled your project
yet. In which case what you'd need would be a sourcepath rather
than a classpath.
Although I do agree that classpath-based loading is interesting
at run time - it will make it difficult to deal with the file
at design-time - since it requires to set up some config before
you can load the FXML file. At design time, there's also the risk
that the wrong file will be loaded - e.g. that you will load
the obsolete copy of the file present in the build/ directory
instead of loading the brand new file you just dropped in your src/
On the other hand, using the @ notation usually works well both at
runtime and design time - which IMO makes it safer.
On 4/24/12 10:04 AM, openjfx-dev-request at openjdk.java.net wrote:
> Date: Tue, 24 Apr 2012 08:14:25 +0200
> From: Martin Sladecek<martin.sladecek at oracle.com>
> Subject: Re: Image class and paths relative to classpath
> To: Kevin Rushforth<kevin.rushforth at oracle.com>
> Cc: Daniel Zwolenski<zonski at googlemail.com>,
> "openjfx-dev at openjdk.java.net"<openjfx-dev at openjdk.java.net>
> Message-ID:<4F9644C1.1030002 at oracle.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> I checked FXML and both relative and absolute paths work well when using
> "@" prefix, so I don't see a problem here. I have to check CSS.
More information about the openjfx-dev