How to use the .properties files during runtime

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

How to use the .properties files during runtime

Postby Baileys » Tue Apr 08, 2008 10:14 am


I've used the I18n feature to generate the properties files for my Test app. I have configured 2 locales : default and fr_CA.
Now I would like to change the language during runtime, from a menu entry or a function key.
How would you do that?
Do I have to reload the BUNDLE with code like this :

Code: Select all
BUNDLE = ResourceBundle.getBundle("", Locale.CANADA_FRENCH);

I'm new to this, sorry if it's a noob's question ;)
Posts: 22
Joined: Thu Oct 20, 2005 6:18 am
Location: Montreal

Re: How to use the .properties files during runtime

Postby Eric Clayberg » Tue Apr 08, 2008 10:58 am

I have no idea how you would do that (we've never had a reason to do that since Java selects the current locale at application startup).

Even if you programatically change the locale, you still need to update all of the widgets (probably by closing and re-opening any affected windows).

If you want to realy switch languages on the fly, you are going to have to write (or find) a lot of code. Swing by itself won't do that.
Eric Clayberg
Software Engineering Manager

Author: "Eclipse Plug-ins"
Eric Clayberg
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest