Skip to main content



      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 18:37 Go to next message
Eclipse UserFriend
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] Wed, 08 January 2014 19:19 Go to previous message
Eclipse UserFriend
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: Sat Jul 05 00:25:56 EDT 2025

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

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

Back to the top