Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2008

Tip: Looking for answers? Try searching our database.

Switching languages in Swing GUI on the fly

Thread view: 
David ‘Bombe’ Roden - 08 Mar 2008 13:45 GMT
Hi, everyone.

I'm currently creating a program that will be translated to at least three
different languages. I want it to be possible to change languages on the
fly. So far I've been using Runnables that set the texts on all components
when the language is changed. Is that the way to go or is there something
simpler that I have missed so far?

Thanks,

       David
CK - 08 Mar 2008 16:23 GMT
Words to the wise, David ‘Bombe’ Roden <bombe@pterodactylus.net>
wrote:

>Hi, everyone.
>
[quoted text clipped - 3 lines]
>when the language is changed. Is that the way to go or is there something
>simpler that I have missed so far?

You could implement a controller which just listens to whether the
language is being changed and which then iterates over all controls
and sets the corresponding string from a resource bundle depending on
the new language string. Whether that is simpler than your solution, I
cannot say.
--
Claus Dragon <clauskick@mpsahotmail.com>
=(UDIC)=
d++ e++ T--
K1!2!3!456!7!S a29
"Coffee is a mocker. So, I am going to mock."

- Me, lately.
Roedy Green - 21 Mar 2008 13:08 GMT
On Sat, 08 Mar 2008 14:45:44 +0100, David ‘Bombe’ Roden
<bombe@pterodactylus.net> wrote, quoted or indirectly quoted someone
who said :

>I'm currently creating a program that will be translated to at least three
>different languages. I want it to be possible to change languages on the
>fly. So far I've been using Runnables that set the texts on all components
>when the language is changed. Is that the way to go or is there something
>simpler that I have missed so far?

see http://mindprod.com/jgloss/localisation.html
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Karsten Lentzsch - 22 Mar 2008 10:52 GMT
> see http://mindprod.com/jgloss/localisation.html

Just a note about internationalization and localization.
These are not the same. The first is the process of
preparing a system for different locales, where the second
is the concrete work where the prepared system gets support
for a new locale.

-Karsten
Roedy Green - 09 Apr 2008 06:55 GMT
On Sat, 22 Mar 2008 10:52:33 +0100, Karsten Lentzsch
<karsten@jgoodies.com> wrote, quoted or indirectly quoted someone who
said :

>> see http://mindprod.com/jgloss/localisation.html
>
[quoted text clipped - 3 lines]
>is the concrete work where the prepared system gets support
>for a new locale.

Thanks. I have added that observation to the entry.
Signature


Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Karsten Lentzsch - 22 Mar 2008 10:50 GMT
> I'm currently creating a program that will be translated to at least three
> different languages. I want it to be possible to change languages on the
> fly. So far I've been using Runnables that set the texts on all components
> when the language is changed. Is that the way to go or is there something
> simpler that I have missed so far?

You don't necessarily need Runnables. You can change
localized texts in the Event-Dispatch-Thread.

A workable approach is to have custom components,
for example an on-the-fly-label that stores a key
for the text lookup, listens to a custom property
that notifies the component when the Locale has changed.
On Locale change, the component can update its text
by re-reading the resource for its key.

Note that Locale has no bound property that can be
observed for that case. So a common approach is to
set a new Locale and then fire a change in a custom
(bean) property somewhere.

-Karsten


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.