Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CSS Image loading problem by dynamically loading from fxml file?

963802Jan 3 2013 — edited Jan 4 2013
h1. Introduction
The application I am developing loads an FXML file from a Controller. The FXML uses CSS and images for buttons are set in the CSS.

CSS directory structure
<package>.fxml

Images
<package>.fxml.resources.<subdir>

Example CSS Code
.buttonImage {
    -fx-background-image: url("resources/subdir/image.png"); 
}
Example loading fxml from controller code
	    URL location = getClass().getResource("/package/fxml/UI.fxml");
	    FXMLLoader fxmlLoader = new FXMLLoader(location);
	    fxmlLoader.setLocation(location);
	    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
	    Parent root = (Parent)fxmlLoader.load(location.openStream());
	    Controller = (Controller) fxmlLoader.getController();
	    newPane.getChildren().add(root);
h1. Problem
The fxml file does not load and causes the following error:
javafx.fxml.LoadException: Page language not specified.
Note, the fxml file loaded correctly before images were added.

Any ideas of what might be going wrong?

h1. Attempted
I have attempted the following: tried changing the url of the image as an absolute path.
This post has been answered by TomSchindl on Jan 4 2013
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 1 2013
Added on Jan 3 2013
5 comments
1,356 views