File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JavaFX and the fly likes JavaFx internationalization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "JavaFx internationalization" Watch "JavaFx internationalization" New topic

JavaFx internationalization

Jorge Sereno

Joined: Jun 30, 2012
Posts: 9
I'm looking to do some internationalization in my working example of javafx.
I've looked in the internet and i found no valuable information how to do this.
I'm using a resource bundle but i don´t no how to update the rendered elements in the window to the new resource bundle.

Here's my example code:

the bundles are


How can i refresh all the elements in my scene to get the new value from bundle
when i press one of the language buttons.

Anyone can help me in that?
Thankx in advance
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 227
If your components are defined in code rather than fxml you will currently (with JavaFX 2.2) need to create the infrastructure yourself.

Quick algorithm off the top of my head:
1. assign an id to each labeled or text node (setId).
2. use the text key strings in your resource bundle which match your node id.
3. create a resourcebundle property on your scene.
4. attach a resourcebundle property ChangeListener.
5. when the resourcebundle for the scene changes:
a. iterate through all your text keys from the resource bundle.
b. invoke the node.lookup(textKeyId) function for each text key.
c. call node.setText(rb.getString(textKeyId)).

If you use fxml, see here for info on how to hook up resources:

If you use SceneBuilder, follow this guide to internationalize your app:

Also, see the example in this stackoverflow question (also an fxml variant):
I agree. Here's the link:
subject: JavaFx internationalization
It's not a secret anymore!