[SOLVED] JavaFX style-sheet not displaying using jmejfx

I am using the latest jme javafx library and 3.1 alpha 3. I tried defining the .css in the .fxml file, tried applying it manually on my FXMLHud through addStyleSheet() and even tried to add it mabually on my root node of the FXMLHud. It does not get applied at run-time. No errors so I know my resource path is correct. When I apply it on the ,fxml file it comes up nicely in the preview view of SceneBuilder.

Has anyone run into this problem?

I used an other approach to apply CSS:

	static void initGui(GuiManager guiManager) {
		//see http://blog.idrsolutions.com/2014/04/use-external-css-files-javafx/
		Scene scene = guiManager.getjmeFXContainer().getScene();
		FxPlatformExecutor.runOnFxApplication(() -> {
			Font.loadFont(MainApp.class.getResource("/Fonts/Eduardo-Barrasa.ttf").toExternalForm(), 10);
			Font.loadFont(MainApp.class.getResource("/Fonts/bobotoh.ttf").toExternalForm(), 10);
			String css = MainApp.class.getResource("/Interface/main.css").toExternalForm();

Never thought of adding the style-sheet to the scene instead of the hud nodes. Works perfectly! Thank you!

If you only want it for one hud:

	this.editorHud = new FXMLHud<EditorHudController>("de/visiongamestudios/client/editor/editorScreen.fxml") {
		protected ResourceBundle addCustomRessources(final ResourceBundle ressources) {
			return I18NProvider.getBundle();

You need to do this before precaching or adding it to the GuiManager. Btw. that way seen above you can register your message bundles :slight_smile:

1 Like