0

I would like to know if this is possible in java that i want to reload a swing app so that i can set locale. Im working on a swing app project where more than 5 languages used and i have already created property file for each language. Whenever user selects a new language from menu my app has to restart to change the selected language. Im totally stuck here as how to restart my swing app with my loaded vm arguments and new language.

For reference here is the website which has the same requirement as what i expect. http://teravoice.com/

After web-page loads select a link which download a jnlp and once app opens, please login with any name and in the file menu you find a sub menu "language" with 12 languages. when i click on a new language the app restarts itself with the new language and with user data (i.e. vm options).

Thank you.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Dinesh Ravichandran
  • 312
  • 1
  • 5
  • 16

1 Answers1

7

that's simple possible two ways by using ResourceBundle and Locale

1) take Locale from Native OS Locale.getDefault()

ResourceBundle rb = ResourceBundle.getBundle(
       "com.MyPackage.Properties", Locale.getDefault());

frameTitle = (rb.getString("MyFrame.Title")); //myFrame.setTitle("frameTitle");
trayTitle = (rb.getString("MyFrame.TrayTitle"));
exitTitle = (rb.getString("MyFrame.Exit"));
newInfoTitle = (rb.getString("MyFrame.NewInfo"));
sendTitle = (rb.getString("MyFrame.Send"));

2) set Locale on Runtime, f.e by selecting Item in the JComboBox, then you have to refresh (better would be to create separated method, void or class) all JComponents or methods, all changes must be done on Event Dispatch Thread

3) some examples about I18

4) I'm IDE user and for Locale I use built-in editor for properties File,

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • can you provide me a dummy project using netbeans.. im a bit confused on how it works.. if i get a sample code it would be better for me to understand.. thank you.. – Dinesh Ravichandran Jan 19 '12 at 22:20
  • nothing complicated to try http://netbeans.org/kb/docs/java/gui-automatic-i18n.html, – mKorbel Jan 19 '12 at 22:35
  • thanks mkorbel i made the language pack to work.. now im stuck in another situation where i packed my library class file using pack200 compression from 13mb to 4mb. but when deploying through webstart i get error message on compressed library jar file that "could not verify signing in resources". I signed the source and library jar file through netbeans. – Dinesh Ravichandran Jan 21 '12 at 09:56
  • JWS isn't my area, you have got these choices 1) search on this forum and then ask a new question, 2) search in @Andrew Thompson http://stackoverflow.com/users/418556/andrew-thompson profile (author of lots of documents about Applet/JApplet/JWS) 3) post here detailed question by hoping that Andrew touching that :-) – mKorbel Jan 21 '12 at 10:16
  • hi mkorbel here is the link of my new question... hoping for a reply.. http://stackoverflow.com/questions/8952912/error-opening-library-file-compressed-with-pack200-compression – Dinesh Ravichandran Jan 21 '12 at 12:22