Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Access FXML locate in another Package.
Access FXML locate in another Package. [message #1229206] Wed, 08 January 2014 23:37 Go to next message
Ghislain Mustermann is currently offline Ghislain MustermannFriend
Messages: 24
Registered: April 2013
Junior Member
I'm following the Tutorial 1. And now i create several Package an want to access from a Class a FXML Files. I done this into my class :

			BorderPane root = (BorderPane) FXMLLoader.load(new URL(
					"/src/com/guidemo/Sample.fxml"));
			System.out.println(root);
			Scene scene = new Scene(root, 400, 400);
			scene.getStylesheets().add(
					getClass().getResource("application.css").toExternalForm());
			primaryStage.setScene(scene);
			primaryStage.show();


But unfortunaly FXMLLoader cant found the fxml. Into an Osgi Environment i know how to do... But for JavaFx Project i really dont know how to access an File in another package. The "application.css" is located too into another package.

How to find these Files while running an e(fx)clipse JavaFx Project?
Re: Access FXML locate in another Package. [message #1229216 is a reply to message #1229206] Thu, 09 January 2014 00:19 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
The construction of the URL is simply wrong:
a) you do it relative to the class-File you are in
getClass().getResource("Sample.fxml")
b) you do it relative to the classloader
getClass().getClassloader().getResource("com/guidemo/Sample.fxml");

Please note that with a) you can not do .. locations because this is
generally not supported in the JAR-Filesystem

Tom

On 09.01.14 00:37, Ghislain Mustermann wrote:
> I'm following the Tutorial 1. And now i create several Package an want
> to access from a Class a FXML Files. I done this into my class :
>
>
> BorderPane root = (BorderPane) FXMLLoader.load(new URL(
> "/src/com/guidemo/Sample.fxml"));
> System.out.println(root);
> Scene scene = new Scene(root, 400, 400);
> scene.getStylesheets().add(
>
> getClass().getResource("application.css").toExternalForm());
> primaryStage.setScene(scene);
> primaryStage.show();
>
>
> But unfortunaly FXMLLoader cant found the fxml. Into an Osgi Environment
> i know how to do... But for JavaFx Project i really dont know how to
> access an File in another package. The "application.css" is located too
> into another package.
>
> How to find these Files while running an e(fx)clipse JavaFx Project?
Previous Topic:contribute to context menu from E3 plugin in FXML view?
Next Topic:We have successfully passed the IP-Review
Goto Forum:
  


Current Time: Fri Mar 29 07:37:48 GMT 2024

Powered by FUDForum. Page generated in 0.03046 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top