I can only get this to work via a pretty massive hack, that isn't even remotely portable. However, maybe it will give you enough to work from to create a viable solution. (This works under Java 8.)
I created a package com.sun.javafx.scene.control.skin.resources
, and created a controls_fi_FI.properties file in it with the single line
ProgressIndicator.doneString=Valmis
I created a test app with the following:
import java.util.Locale;
import java.util.ResourceBundle;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.BorderPane;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
System.out.println(ResourceBundle.getBundle("com/sun/javafx/scene/control/skin/resources/controls").getString("ProgressIndicator.doneString"));
BorderPane root = new BorderPane();
ProgressIndicator progressIndicator = new ProgressIndicator(1);
root.setCenter(progressIndicator);
Scene scene = new Scene(root,400,400);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
Locale.setDefault(new Locale("fi", "FI"));
launch(args);
}
}
Running this app most ways doesn't work as desired: while the System.out.println(...)
produces the correct result, the text displayed in the progress indicator is wrong.
However, if I bundle com/sun/javafx/control/skin/resources/controls_fi_FI.properties
in a jar file, and move that jar file to the jre/lib/ext
subdirectory of my JDK installation (ie. the same location as jfxrt.jar
), it runs as required (at least in my simple test; as I said, I make no claims for this to be any kind of robust solution).
The issue appears to be that ControlsResources
is being loaded by the extension class loader, and so is using the same class loader to load the resource bundle.
With better knowledge of class loaders than I have, you might be able to mold this into a reasonable solution...
ResourceBundle
defined by a properties file in the classpath should work. Can you show how you are retrieving values from your bundle? – Helainehelali