Resource Bundle - LoadException: No resources specified

360 views
Skip to first unread message

Chris Morgan

unread,
Dec 30, 2015, 11:52:52 PM12/30/15
to DataFX
I am new to DataFX and struggling to get localisation working. My main class is as shown:

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        //set language
        ViewConfiguration viewConfig = new ViewConfiguration();
        Locale locale = new Locale("en","EN");
        viewConfig.setResources(ResourceBundle.getBundle(UIConstants.LANGUAGE_BUNDLE_PREFIX, locale));

        Flow applicationRootFlow = new Flow(HomeController.class, viewConfig);
        FlowHandler applicationRootFlowHandler = applicationRootFlow.createHandler();

        StackPane root = applicationRootFlowHandler.start(new DefaultFlowContainer());
        primaryStage.setScene(new Scene(root, UIConstants.APPLICATION_WIDTH, UIConstants.APPLICATION_HEIGHT));
        primaryStage.setTitle(UIConstants.APPLICATION_TITLE);
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}

I have traced the code through, and the debug shows the Flow has loaded the resource successfully (see attached image).

 The resource has the required index, but the fxml is not loading the string, instead crashing with 
Caused by:... javafx.fxml.LoadException: No resources specified. /C:/.../Home.fxml:22

The line in the fxml is:
<Label fx:id="languageLabel" text="%displayLanguage" />

The resource bundle is:
applicationTitle=Service222222
displayLanguage=English


debug.png
Reply all
Reply to author
Forward
0 new messages